[Adduser-devel] Bug#121262: adduser skel_regex patch

Stephen Gran steve at lobefin.net
Tue Feb 7 22:56:22 UTC 2006


Patch attached.

As we discussed on IRC, having this option be settable in the config
file might be a nice addition.  This should do it.

diff -Nru adduser-3.82.old/adduser adduser-3.82/adduser
--- adduser-3.82.old/adduser    2006-02-05 20:14:32.000000000 +0000
+++ adduser-3.82/adduser    2006-02-07 22:46:59.000000000 +0000
@@ -569,11 +569,12 @@

       if ($config{"skel"} && $copy_skeleton) {
      printf gtx("Copying files from `%s'\n"),$config{skel} if $verbose;
-     open(FIND, "cd $config{skel}; find .  ! -name '*.dpkg-*' -print |")
+     open(FIND, "cd $config{skel}; find . -print |")
          || &cleanup("fork for find: $!\n");
      while (<FIND>) {
          chop;
          next if ($_ eq ".");
+         next if ($_ =~ qr/$config{skel_ignore_regex}/);
          &copy_to_dir($config{"skel"}, $_, $home_dir, $new_uid,
                $new_gid, ($config{"setgid_home"} =~ /yes/i));
      }
diff -Nru adduser-3.82.old/AdduserCommon.pm adduser-3.82/AdduserCommon.pm
--- adduser-3.82.old/AdduserCommon.pm   2005-11-18 17:25:36.000000000 +0000
+++ adduser-3.82/AdduserCommon.pm   2006-02-07 22:42:34.000000000 +0000
@@ -197,6 +197,7 @@
   $configref->{"setgid_home"} = "no";
   $configref->{"no_del_paths"} = "^/$ ^/lost+found/.* ^/media/.* ^/mnt/.* ^/etc/.* ^/bin/.* ^/boot/.* ^/dev/.* ^/lib/.* ^/proc/.* ^/root/.* ^/sbin/.* ^/tmp/.* ^/sys/.* ^/srv
/.* ^/opt/.* ^/initrd/.* ^/usr/.* ^/var/.*";
   $configref->{"name_regex"} = "^[a-z][-a-z0-9]*\$";
+  $configref->{"skel_ignore_regex"} = "dpkg-(old|new|dist)";

   foreach( @$conflistref ) {
       read_config($_,$configref);
diff -Nru adduser-3.82.old/adduser.conf adduser-3.82/adduser.conf
--- adduser-3.82.old/adduser.conf   2005-11-18 17:21:05.000000000 +0000
+++ adduser-3.82/adduser.conf   2006-02-07 22:41:41.000000000 +0000
@@ -58,3 +58,8 @@
 # `edquota -p QUOTAUSER newuser'
 QUOTAUSER=""

+# If SKEL_IGNORE_REGEX is set, adduser will ignore files matching this
+# regular expression when creating a new home directory
+
+SKEL_IGNORE_REGEX="dpkg-(old|new|dist)"
+
diff -Nru adduser-3.82.old/doc/adduser.conf.5 adduser-3.82/doc/adduser.conf.5
--- adduser-3.82.old/doc/adduser.conf.5 2005-08-16 14:25:59.000000000 +0100
+++ adduser-3.82/doc/adduser.conf.5 2006-02-07 22:53:09.000000000 +0000
@@ -110,6 +110,12 @@
 doesn't match this regexp, user creation is refused unless
 --force-badname is set. With --force-badname set, only weak checks are
 performed. The default is the most conservative ^[a-z][-a-z0-9]*$.
+.TP
+\fBSKEL_IGNORE_REGEX\fB
+Files in /etc/skel/ are checked against this regex, and not copied to
+the newly created home directory if they match.  This is by default set
+to the regular expression matching files left over from unmerged config
+files (dpkg-(old|new|dist)).
 .SH FILES
 .I /etc/adduser.conf
 .SH SEE ALSO

-- 
 --------------------------------------------------------------------------
|  Stephen Gran                  | Show your affection, which will         |
|  steve at lobefin.net             | probably meet with pleasant response.   |
|  http://www.lobefin.net/~steve |                                         |
 --------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/adduser-devel/attachments/20060207/2581062f/attachment-0001.pgp


More information about the Adduser-devel mailing list