/usr/sbin
NameSizeModeActions
accessdb128880755editdlrm
accton140160755editdlrm
addgnupghome30750755editdlrm
addpart254560755editdlrm
adduser1517200755editdlrm
agetty638880755editdlrm
alternatives375360755editdlrm
anacron419760755editdlrm
apachectl48040755editdlrm
applygnupgdefaults22170755editdlrm
arp662640755editdlrm
arpd1121520755editdlrm
arping294320755editdlrm
atd334080755editdlrm
atrun670755editdlrm
authconfig220570755editdlrm
avcstat167920755editdlrm
badblocks333680755editdlrm
blkdeactivate163510555editdlrm
blkdiscard297520755editdlrm
blkid1010240755editdlrm
blkmapd547520755editdlrm
blkzone509440755editdlrm
blockdev422960755editdlrm
bridge1620480755editdlrm
build-locale-archive8612480700editdlrm
capsh332240755editdlrm
cfdisk1007680755editdlrm
chcpu295200755editdlrm
chgpasswd713600755editdlrm
chkconfig461920755editdlrm
chpasswd628960755editdlrm
chroot424480755editdlrm
clock667840755editdlrm
clockdiff209200755editdlrm
consoletype121440755editdlrm
convertquota805680755editdlrm
cracklib-check133600755editdlrm
cracklib-format2510755editdlrm
cracklib-packer133680755editdlrm
cracklib-unpacker92480755editdlrm
create-cracklib-dict9900755editdlrm
crond757120755editdlrm
csf2509790700editdlrm
ctrlaltdel253840755editdlrm
ctstat259360755editdlrm
dcb1587600755editdlrm
ddns-confgen209520755editdlrm
debugfs2371840755editdlrm
delpart254560755editdlrm
depmod1637840755editdlrm
devlink2210480755editdlrm
dhclient4645680755editdlrm
dhclient-script336460755editdlrm
dmfilemapd251360555editdlrm
dmsetup1624480555editdlrm
dmstats1624480555editdlrm
dnssec-checkds9360755editdlrm
dnssec-coverage9380755editdlrm
dnssec-dsfromkey623040755editdlrm
dnssec-importkey622960755editdlrm
dnssec-keyfromlabel663120755editdlrm
dnssec-keygen745840755editdlrm
dnssec-keymgr9340755editdlrm
dnssec-revoke581040755editdlrm
dnssec-settime623040755editdlrm
dnssec-signzone1200160755editdlrm
dnssec-verify541120755editdlrm
dovecot1660720755editdlrm
dovecot_cpshutdown33440755editdlrm
dpkg-fsys-usrunmess123990755editdlrm
dump-acct298480755editdlrm
dump-utmp256160755editdlrm
dumpe2fs332960755editdlrm
e2freefrag168160755editdlrm
e2fsck3364000755editdlrm
e2image374880755editdlrm
e2label1132800755editdlrm
e2mmpstatus332960755editdlrm
e2undo208640755editdlrm
e4crypt251360755editdlrm
e4defrag291760755editdlrm
edquota934320755editdlrm
ether-wake757680755editdlrm
ethtool5711760755editdlrm
exicyclog113650755editdlrm
exigrep117100755editdlrm
exim17050964755editdlrm
eximstats1525460755editdlrm
exim_checkaccess49430755editdlrm
exim_dbmbuild246880755editdlrm
exim_dumpdb601120755editdlrm
exim_fixdb656560755editdlrm
exim_lock272240755editdlrm
exim_tidydb561200755editdlrm
exinext82170755editdlrm
exiqgrep67390755editdlrm
exiqsumm64430755editdlrm
exiwhat45240755editdlrm
exportfs843520755editdlrm
faillock210160755editdlrm
fcgistarter175200755editdlrm
fdformat339680755editdlrm
fdisk1340480755editdlrm
filefrag168560755editdlrm
findfs126720755editdlrm
fix-info-dir80330755editdlrm
fixfiles107270755editdlrm
fsck547520755editdlrm
fsck.cramfs424080755editdlrm
fsck.ext23364000755editdlrm
fsck.ext33364000755editdlrm
fsck.ext43364000755editdlrm
fsck.minix1011200755editdlrm
fsfreeze167760755editdlrm
fstrim507920755editdlrm
fuse2fs720800755editdlrm
fuser390560755editdlrm
g13-syshelp1943120755editdlrm
genhomedircon299760755editdlrm
genhostid121440755editdlrm
genl1243200755editdlrm
genrandom126720755editdlrm
getcap126480755editdlrm
getenforce80240755editdlrm
getpcaps125680755editdlrm
getsebool121520755editdlrm
groupadd976320755editdlrm
groupdel932800755editdlrm
groupmems629600755editdlrm
groupmod1017600755editdlrm
grpck629440755editdlrm
grpconv586400755editdlrm
grpunconv586320755editdlrm
grub2-bios-setup12139840755editdlrm
grub2-get-kernel-settings27420755editdlrm
grub2-install15114640755editdlrm
grub2-mkconfig88880755editdlrm
grub2-probe12139280755editdlrm
grub2-reboot40850755editdlrm
grub2-rpm-sort2899360755editdlrm
grub2-set-bootflag167444755editdlrm
grub2-set-default35350755editdlrm
grub2-set-password31190755editdlrm
grub2-setpassword31190755editdlrm
grub2-switch-to-blscfg88090755editdlrm
grubby2600755editdlrm
gss-server252000755editdlrm
gssproxy1352480755editdlrm
halt2236960755editdlrm
hardlink174960755editdlrm
htcacheclean454240755editdlrm
httpd10152560755editdlrm
hwclock667840755editdlrm
iconvconfig338400755editdlrm
ifconfig828000755editdlrm
ifdown21230755editdlrm
ifenslave255440755editdlrm
ifstat1204960755editdlrm
ifup54630755editdlrm
init16136240755editdlrm
insmod1637840755editdlrm
install-info514320755editdlrm
installkernel3230755editdlrm
ip7099440755editdlrm
ip6tables943920755editdlrm
ip6tables-legacy943920755editdlrm
ip6tables-legacy-restore943920755editdlrm
ip6tables-legacy-save943920755editdlrm
ip6tables-restore943920755editdlrm
ip6tables-save943920755editdlrm
ipmaddr215040755editdlrm
ipset92240755editdlrm
iptables943920755editdlrm
iptables-legacy943920755editdlrm
iptables-legacy-restore943920755editdlrm
iptables-legacy-save943920755editdlrm
iptables-restore943920755editdlrm
iptables-save943920755editdlrm
iptraf-ng1891040755editdlrm
iptunnel256000755editdlrm
isc-hmac-fixup121440755editdlrm
key.dns_resolver251040755editdlrm
kpartx502320755editdlrm
lchage168000755editdlrm
ldattach337840755editdlrm
ldconfig10097680755editdlrm
lfd3916290700editdlrm
lgroupadd121600755editdlrm
lgroupdel121600755editdlrm
lgroupmod203520755editdlrm
lid166640755editdlrm
lnewusers203440755editdlrm
lnstat259360755editdlrm
load_policy125760755editdlrm
logrotate952640755editdlrm
logsave168000755editdlrm
losetup927680755editdlrm
lpasswd208400755editdlrm
lsmod1637840755editdlrm
luseradd203520755editdlrm
luserdel162560755editdlrm
lusermod203600755editdlrm
lwresd8611200755editdlrm
mariadbd254524800755editdlrm
matchpathcon126640755editdlrm
mii-diag260080755editdlrm
mii-tool215360755editdlrm
mkdict2510755editdlrm
mke2fs1417680755editdlrm
mkfs168720755editdlrm
mkfs.cramfs422560755editdlrm
mkfs.ext21417680755editdlrm
mkfs.ext31417680755editdlrm
mkfs.ext41417680755editdlrm
mkfs.minix886400755editdlrm
mkhomedir_helper250240755editdlrm
mklost+found121440755editdlrm
mkswap885520755editdlrm
modinfo1637840755editdlrm
modprobe1637840755editdlrm
modsec-sdbm-util264480750editdlrm
mount.nfs2019764755editdlrm
mount.nfs42019764755editdlrm
mountstats432370755editdlrm
mysqld254524800755editdlrm
named8611200755editdlrm
named-checkconf417680755editdlrm
named-checkzone375120755editdlrm
named-compilezone375120755editdlrm
named-journalprint121360755editdlrm
nameif173840755editdlrm
newusers1098000755editdlrm
nfsconf383760755editdlrm
nfsconvert133470755editdlrm
nfsdcld674480755editdlrm
nfsdclddb102420755editdlrm
nfsdclnts92330755editdlrm
nfsdcltrack509760755editdlrm
nfsidmap464480755editdlrm
nfsiostat239220755editdlrm
nfsref673760755editdlrm
nfsstat363680755editdlrm
nft249920755editdlrm
nologin121520755editdlrm
nscd1604480755editdlrm
nsec3hash125840755editdlrm
nstat1162960755editdlrm
ntsysv419520755editdlrm
oddjobd794960755editdlrm
packer133680755editdlrm
pam_console_apply462800755editdlrm
pam_timestamp_check121524755editdlrm
paperconfig41700755editdlrm
partx967680755editdlrm
pidof170960755editdlrm
ping677120755editdlrm
ping6677120755editdlrm
pivot_root126800755editdlrm
plipconfig130160755editdlrm
pluginviewer210640755editdlrm
poweroff2236960755editdlrm
pure-authd196960755editdlrm
pure-certd196000755editdlrm
pure-config.pl47550755editdlrm
pure-ftpd1864400755editdlrm
pure-ftpwho274720755editdlrm
pure-mrtginfo114320755editdlrm
pure-quotacheck192720755editdlrm
pure-uploadscript195360755editdlrm
pwck586400755editdlrm
pwconv543760755editdlrm
pwhistory_helper209200755editdlrm
pwunconv544000755editdlrm
quot805600755editdlrm
quotacheck1185280755editdlrm
quotaoff851520755editdlrm
quotaon851520755editdlrm
quotastats169360755editdlrm
rcmysql-0editdlrm
rdisc251360755editdlrm
rdma1918800755editdlrm
readprofile210400755editdlrm
reboot2236960755editdlrm
repquota852400755editdlrm
request-key249680755editdlrm
resize2fs664720755editdlrm
resizepart425680755editdlrm
resolvconf2004480755editdlrm
restorecon210240755editdlrm
restorecon_xattr168080755editdlrm
rfkill547440755editdlrm
rmmod1637840755editdlrm
rndc374080755editdlrm
rndc-confgen209360755editdlrm
rotatelogs312400755editdlrm
route692480755editdlrm
rpc.gssd1090960755editdlrm
rpc.idmapd632160755editdlrm
rpc.mountd1669520755editdlrm
rpc.nfsd511200755editdlrm
rpc.statd1057760755editdlrm
rpcbind630240755editdlrm
rpcctl96310755editdlrm
rpcdebug198400755editdlrm
rpcinfo334240755editdlrm
rsyslogd7421200755editdlrm
rtacct480640755editdlrm
rtcwake504880755editdlrm
rtmon1200800755editdlrm
rtstat259360755editdlrm
runlevel2236960755editdlrm
runq17050964755editdlrm
runuser501680755editdlrm
sa477360755editdlrm
safe_finger128800755editdlrm
saslauthd966880755editdlrm
sasldblistusers2212640755editdlrm
saslpasswd2168160755editdlrm
sefcontext_compile669200755editdlrm
selabel_digest125760755editdlrm
selabel_lookup125680755editdlrm
selabel_lookup_best_match121760755editdlrm
selabel_partial_match121680755editdlrm
selinuxconlist121600755editdlrm
selinuxdefcon121600755editdlrm
selinuxenabled80240755editdlrm
selinuxexeccon121440755editdlrm
selinux_check_access126560755editdlrm
semanage421710755editdlrm
semodule299760755editdlrm
sendmail173202755editdlrm
service37290755editdlrm
sestatus209040755editdlrm
setcap166640755editdlrm
setenforce125600755editdlrm
setfiles210240755editdlrm
setquota935680755editdlrm
setsebool167680755editdlrm
sfdisk1213520755editdlrm
showmount215680755editdlrm
shutdown2236960755editdlrm
sim_server121520755editdlrm
slattach448080755editdlrm
sm-notify800080755editdlrm
smartctl9241200755editdlrm
smartd7419840755editdlrm
snmpd332320755editdlrm
snmptrapd333840755editdlrm
ss1958880755editdlrm
sshd8905680755editdlrm
start-statd8380755editdlrm
start-stop-daemon470880755editdlrm
suexec259044755editdlrm
sulogin504240755editdlrm
suphp68817604750editdlrm
swaplabel168960755editdlrm
swapoff212480755editdlrm
swapon505920755editdlrm
switch_root168880755editdlrm
sysctl295680755editdlrm
t1libconfig39210755editdlrm
tcpd432560755editdlrm
tcpdmatch475760755editdlrm
tcpdump10570720755editdlrm
tcpslice334160755editdlrm
tcsd3171520755editdlrm
telinit2236960755editdlrm
testsaslauthd170560755editdlrm
tipc1669840755editdlrm
tmpwatch363200755editdlrm
tracepath209280755editdlrm
tracepath6209280755editdlrm
try-from256320755editdlrm
tsig-keygen209520755editdlrm
tune2fs1132800755editdlrm
udevadm4347520755editdlrm
umount.nfs2019764755editdlrm
umount.nfs42019764755editdlrm
unbound-anchor587120755editdlrm
unix_chkpwd377444755editdlrm
unix_update377440700editdlrm
update-alternatives375360755editdlrm
update-smart-drivedb147820755editdlrm
useradd1517200755editdlrm
userdel1098640755editdlrm
userhelper459364711editdlrm
usermod1475680755editdlrm
usernetctl127044755editdlrm
uuserver162560755editdlrm
vdpa1208720755editdlrm
vigr696880755editdlrm
vipw696880755editdlrm
visudo2450240755editdlrm
weak-modules344100755editdlrm
whmapi034969120755editdlrm
whmapi134969120755editdlrm
whmlogin23900755editdlrm
wipefs421040755editdlrm
xinetd1804000755editdlrm
xqmstats168480755editdlrm
xtables-legacy-multi943920755editdlrm
zdump210560755editdlrm
zic540960755editdlrm
zramctl1015040755editdlrm
Edit: /usr/sbin/dpkg-fsys-usrunmess (12399B)
#!/usr/bin/perl # # dpkg-fsys-usrunmess - Undoes the merged-/usr-via-aliased-dirs mess # # Copyright © 2020-2021 Guillem Jover # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see use strict; use warnings; use feature qw(state); our ($PROGNAME) = $0 =~ m{(?:.*/)?([^/]*)}; our $PROGVERSION = '1.20.9'; our $ADMINDIR = '/var/lib/dpkg'; use POSIX; use Getopt::Long qw(:config posix_default bundling_values no_ignorecase); eval q{ pop @INC if $INC[-1] eq '.'; use File::FcntlLock; }; if ($@) { fatal('missing File::FcntlLock module; please install libfile-fcntllock-perl'); } my $opt_noact = length $ENV{DPKG_USRUNMESS_NOACT} ? 1 : 0; my $opt_prompt = 0; my @options_spec = ( 'help|?' => sub { usage(); exit 0; }, 'version' => sub { version(); exit 0; }, 'dry-run|no-act|n' => \$opt_noact, 'prompt|p' => \$opt_prompt, ); { local $SIG{__WARN__} = sub { usageerr($_[0]) }; GetOptions(@options_spec); } my @aliased_dirs; # # Scan all dirs under / and check whether any are aliased to /usr. # foreach my $path (glob '/*') { debug("checking symlink? $path"); next unless -l $path; debug("checking merged-usr symlink? $path"); my $symlink = readlink $path; next unless $symlink eq "usr$path" or $symlink eq "/usr$path"; debug("merged-usr breakage, queueing $path"); push @aliased_dirs, $path; } if (@aliased_dirs == 0) { print "System is fine, no aliased directories found, congrats!\n"; exit 0; } # # dpkg consistency checks # debug('checking dpkg database consistency'); system(qw(dpkg --audit)) == 0 or fatal("cannot audit the dpkg database: $!"); debug('checking whether dpkg has been interrupted'); if (glob "$ADMINDIR/updates/*") { fatal('dpkg is in an inconsistent state, please fix that'); } my $aliased_regex = '^(' . join('|', @aliased_dirs) . ')/'; # # Get a list of all paths (including diversion) under the aliased dirs. # my @search_args; my %aliased_pathnames; foreach my $dir (@aliased_dirs) { push @search_args, "$dir/*"; } open my $fh_paths, '-|', 'dpkg-query', '--search', @search_args or fatal("cannot execute dpkg-query --search: $!"); while (<$fh_paths>) { if (m/^diversion by [^ ]+ from: .*$/) { # Ignore. } elsif (m/^diversion by [^ ]+ to: (.*)$/) { if (-e $1) { add_pathname($1, 'diverted pathname'); } } elsif (m/^.*: (.*)$/) { add_pathname($1, 'pathname'); } } close $fh_paths; # # Get a list of all update-alternatives under the aliased dirs. # my @selections = qx(update-alternatives --get-selections); foreach my $selection (@selections) { my $name = (split(' ', $selection))[0]; my $slaves = 0; open my $fh_alts, '-|', 'update-alternatives', '--query', $name or fatal("cannot execute update-alternatives --query: $!"); while (<$fh_alts>) { if (m/^\s*$/) { last; } elsif (m/^Link: (.*)$/) { add_pathname($1, 'alternative link'); } elsif (m/^Slaves:\s*$/) { $slaves = 1; } elsif ($slaves and m/^\s\S+\s(\S+)$/) { add_pathname($1, 'alternative slave'); } else { $slaves = 0; } } close $fh_alts; } my $sroot = '/.usrunmess'; my @relabel; # # Create a shadow hierarchy under / for the new unmessed dir: # debug("creating shadow dir = $sroot"); mkdir $sroot or sysfatal("cannot create directory $sroot"); foreach my $dir (@aliased_dirs) { debug("creating shadow dir = $sroot$dir"); mkdir "$sroot$dir" or sysfatal("cannot create directory $sroot$dir"); push @relabel, "$sroot$dir"; } # # Populate the split dirs with hardlinks or copies of the objects from # their counter-parts in /usr. # foreach my $pathname (sort keys %aliased_pathnames) { my (@meta) = lstat $pathname or sysfatal("cannot lstat object $pathname for shadow hierarchy"); if (-d _) { my $mode = $meta[2]; my ($uid, $gid) = @meta[4, 5]; my ($atime, $mtime, $ctime) = @meta[8, 9, 10]; debug("creating shadow dir = $sroot$pathname"); mkdir "$sroot$pathname" or sysfatal("cannot mkdir $sroot$pathname"); chmod $mode, "$sroot$pathname" or sysfatal("cannot chmod $mode $sroot$pathname"); chown $uid, $gid, "$sroot$pathname" or sysfatal("cannot chown $uid $gid $sroot$pathname"); utime $atime, $mtime, "$sroot$pathname" or sysfatal("cannot utime $atime $mtime $sroot$pathname"); push @relabel, "$sroot$pathname"; } elsif (-f _) { debug("creating shadow file = $sroot$pathname"); copy("/usr$pathname", "$sroot$pathname"); } elsif (-l _) { my $target = readlink "/usr$pathname"; debug("creating shadow symlink = $sroot$pathname"); symlink $target, "$sroot$pathname" or sysfatal("cannot symlink $target to $sroot$pathname"); push @relabel, "$sroot$pathname"; } else { fatal("unhandled object type for '$pathname'"); } } # # Prompt at the point of no return, if the user requested it. # if ($opt_prompt) { print "Shadow hierarchy created at '$sroot', ready to proceed (y/N)? "; my $reply = ; chomp $reply; if ($reply ne 'y' and $reply ne 'yes') { print "Aborting migration, shadow hierarchy left in place.\n"; exit 0; } } # # Mark all packages as half-configured so that we can force a mass # reconfiguration, to trigger any code in maintainer scripts that might # create files. # # XXX: We do this manually by editing the status file. # XXX: We do this for packages that might not have maintscripts, or might # not involve affected directories. # debug('marking all dpkg packages as half-configured'); if (not $opt_noact) { open my $fh_lock, '>', "$ADMINDIR/lock" or sysfatal('cannot open dpkg database lock file'); my $fs = File::FcntlLock->new(l_type => F_WRLCK); $fs->lock($fh_lock, F_SETLKW) or sysfatal('cannot get a write lock on dpkg database'); my $file_db = "$ADMINDIR/status"; my $file_dbnew = $file_db . '.new'; open my $fh_dbnew, '>', $file_dbnew or sysfatal('cannot open new dpkg database'); open my $fh_db, '<', $file_db or sysfatal('cannot open dpkg database'); while (<$fh_db>) { if (m/^Status: /) { s/ installed$/ half-configured/; } print { $fh_dbnew } $_; } close $fh_db; $fh_dbnew->flush() or sysfatal('cannot flush new dpkg database'); $fh_dbnew->sync() or sysfatal('cannot fsync new dpkg database'); close $fh_dbnew or sysfatal('cannot close new dpkg database'); rename $file_dbnew, $file_db or sysfatal('cannot rename new dpkg database'); } # # Replace things as quickly as possible: # foreach my $dir (@aliased_dirs) { debug("making dir backup = $dir.aliased"); if (not $opt_noact) { rename $dir, "$dir.aliased" or sysfatal("cannot make backup directory $dir.aliased"); } debug("renaming $sroot$dir to $dir"); if (not $opt_noact) { rename "$sroot$dir", $dir or sysfatal("cannot install fixed directory $dir"); } } mac_relabel(); # # Re-configure all packages, so that postinst maintscripts are executed. # debug('reconfigured all packages'); if (not $opt_noact) { local $ENV{DEBIAN_FRONTEND} = 'noninteractive'; system(qw(dpkg --configure --pending)) == 0 or fatal("cannot reconfigure packages: $!"); } # # Cleanup backup directories. # foreach my $dir (@aliased_dirs) { debug("removing backup = $dir.aliased"); if (not $opt_noact) { unlink "$dir.aliased" or sysfatal("cannot cleanup backup directory $dir.aliased"); } } my %deferred_dirnames; # # Cleanup moved objects. # foreach my $pathname (sort keys %aliased_pathnames) { my (@meta) = lstat $pathname or sysfatal("cannot lstat object $pathname for cleanup"); if (-d _) { # Skip directories as this might be shared by a proper path under the # aliased hierearchy. And so that we can remove them in reverse order. debug("deferring merged dir cleanup = /usr$pathname"); $deferred_dirnames{"/usr$pathname"} = 1; } else { debug("cleaning up pathname = /usr$pathname"); next if $opt_noact; unlink "/usr$pathname" or sysfatal("cannot unlink object /usr$pathname"); } } # # Cleanup deferred directories. # debug("cleaning up shadow deferred dir = $sroot"); my $arg_max = POSIX::sysconf(POSIX::_SC_ARG_MAX) // POSIX::_POSIX_ARG_MAX; my @batch_dirs; my $batch_size = 0; foreach my $dir (keys %deferred_dirnames) { my $dir_size = length($dir) + 1; if ($batch_size + $dir_size < $arg_max) { $batch_size += length($dir) + 1; push @batch_dirs, $dir; } else { next; } next if length $batch_size == 0; open my $fh_dirs, '-|', 'dpkg-query', '--search', @batch_dirs or fatal("cannot execute dpkg-query --search: $!"); while (<$fh_dirs>) { if (m/^.*: (.*)$/) { # If the directory is known by its aliased name, it should not be # cleaned up. if (exists $deferred_dirnames{$1}) { delete $deferred_dirnames{$1}; } } } close $fh_dirs; @batch_dirs = (); $batch_size = 0; } if (not $opt_noact) { foreach my $dirname (reverse sort keys %deferred_dirnames) { rmdir $dirname or sysfatal("cannot remove shadow directory $dirname"); } } if (not $opt_noact) { debug("cleaning up shadow root dir = $sroot"); rmdir $sroot or sysfatal("cannot remove shadow directory $sroot"); } print "Done, hierarchy unmessed, congrats!\n"; print "(Note: you might need to run 'hash -r' in your shell.)\n"; 1; ## ## Functions ## sub debug { my $msg = shift; print { \*STDERR } "D: $msg\n"; } sub fatal { my $msg = shift; die "error: $msg\n"; } sub sysfatal { my $msg = shift; fatal("$msg: $!"); } sub copy { my ($src, $dst) = @_; # Try to hardlink first. return if link $src, $dst; # If we are on different filesystems, try a copy. if ($! == POSIX::EXDEV) { # XXX: This will not preserve hardlinks, these would get restored # after the next package upgrade. system('cp', '-a', $src, $dst) == 0 or fatal("cannot copy file $src to $dst: $?"); } else { sysfatal("cannot link file $src to $dst"); } } sub mac_relabel { my $has_cmd = 0; foreach my $path (split /:/, $ENV{PATH}) { if (-x "$path/restorecon") { $has_cmd = 1; last; } } return unless $has_cmd; foreach my $pathname (@relabel) { system('restorecon', $pathname) == 0 or fatal("cannot restore MAC context for $pathname: $?"); } } sub add_pathname { my ($pathname, $origin) = @_; if ($pathname =~ m/$aliased_regex/) { debug("adding $origin = $pathname"); $aliased_pathnames{$pathname} = 1; } } sub version() { printf "Debian %s version %s.\n", $PROGNAME, $PROGVERSION; } sub usage { printf 'Usage: %s [