From: Wichert Akkerman Date: Tue, 13 Jun 2000 17:26:51 +0000 (+0000) Subject: scripts/dpkg-statoverride.pl: X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=add2f2ca3045f3d6a6e104df365d90ab4129cc62;p=dpkg scripts/dpkg-statoverride.pl: + fix two typos in the help message + Add code to implement --update when adding an override scripts/dpkg-statoverride.8: new file debian/dpkg.postinst: create statoverride file if it doesn't exist --- diff --git a/ChangeLog b/ChangeLog index ff7cfa28..3ca9c5c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Jun 13 19:23:37 CEST 2000 Wichert Akkerman + + * scripts/dpkg-statoverride.pl: + + fix two typos in the help message + + Add code to implement --update when adding an override + * scripts/dpkg-statoverride.8: new file + * debian/dpkg.postinst: create statoverride file if it doesn't exist + Mon Jun 12 16:35:26 CEST 2000 Wichert Akkerman * configure.in: generate doc/sv/Makefile as well diff --git a/debian/changelog b/debian/changelog index 5ab40d84..07bc2605 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ dpkg (1.7.0) unstable; urgency=low actual maintainer. Update the format-version to 1.7 to reflect this. * dpkg-genchanges: allow a space between # and a to-be-closed bugnumber * dpkg-deb: reorder files when building a package + * dpkg-statoverride: new tool to override ownership and modes for files -- Wichert Akkerman UNRELEASED diff --git a/debian/dpkg.postinst b/debian/dpkg.postinst index 3c1ce48c..132bb772 100755 --- a/debian/dpkg.postinst +++ b/debian/dpkg.postinst @@ -115,11 +115,13 @@ OK. fi cd /var/lib/dpkg -if ! test -f diversions -then +if ! test -f diversions ; then touch diversions fi +if ! test -f statoverride ; then + touch statoverride +fi rm -f /usr/bin/dpkg-deb.dist if test -d /DEBIAN diff --git a/scripts/dpkg-statoverride.pl b/scripts/dpkg-statoverride.pl index 8e3a6266..6d74aaac 100755 --- a/scripts/dpkg-statoverride.pl +++ b/scripts/dpkg-statoverride.pl @@ -10,7 +10,7 @@ $mode= ""; sub UsageVersion { print STDERR < set the directory with the statoverride file EOF } @@ -73,10 +73,23 @@ $dowrite=0; if ($mode eq "add") { @ARGV==4 || &badusage("--add needs four arguments"); + $user=$ARGV[0]; - ($user =~ m/^#[0-9]*/ or (($tmp)=getpwnam($user))) || &badusage("illegal user $user"); + if ($user =~ m/^#\(0-9+\)$/) { + $uid=$1; + &badusage("illegal user $user") if ($uid<0); + } else { + (($name,$pw,$uid)=getpwnam($user)) || &badusage("non-existing user $user"); + } + $group=$ARGV[1]; - ($group =~ m/^#[0-9]*/ or (($tmp)=getgrnam($group))) || &badusage("illegal group $group"); + if ($group =~ m/^#\(0-9+\)$/) { + $gid=$1; + &badusage("illegal group $group") if ($gid<0); + } else { + (($name,$pw,$gid)=getgrnam($group)) || &badusage("illegal group $group"); + } + $mode= $ARGV[2]; (($mode<0) or ($mode>07777)) && &badusage("illegal mode $mode"); $file= $ARGV[3]; @@ -95,6 +108,15 @@ if ($mode eq "add") { $group{$file}=$group; $mode{$file}=$mode; $dowrite=1; + + if ($doupate) { + if (not -f $file) { + print STDERR "waring: --update given but $file does not exist\n"; + } else { + chmod $mode,$file || warn "failed to chmod $file: $!\n"; + chown $uid,$gid,$file || warn "failed to chown $file: $!\n"; + } + } } elsif ($mode eq "remove") { @ARGV==1 || &badusage("--remove needs four arguments"); $file=$ARGV[0]; @@ -106,6 +128,7 @@ if ($mode eq "add") { delete $group{$file}; delete $mode{$file}; $dowrite=1; + print STDERR "warning: --update is useless for --remove\n" if ($doupdate); } elsif ($mode eq "list") { my (@list,@ilist,$pattern,$file); @@ -164,3 +187,5 @@ sub WriteOverrides { sub quit { print STDERR "dpkg-statoverride: @_\n"; exit(2); } sub badusage { print STDERR "dpkg-statoverride: @_\n\n"; print("You need --help.\n"); exit(2); } + +# vi: ts=8 sw=8 ai si cindent