user [email protected]
usertag 36019 + ubuntu-patch lucid
tag 36019 + patch
thanks

How about the attached patch as a starting point?  It adds:
/usr/share/adduser/add-user.d/
/usr/share/adduser/del-user.d/
/usr/share/adduser/add-group.d/
/usr/share/adduser/del-group.d/
/etc/adduser/add-user.d/
/etc/adduser/del-user.d/
/etc/adduser/add-group.d/
/etc/adduser/del-group.d/

Which all do as you would expect.  All the directories get passed to
run-parts after the appropriate event (adding/deleting users/groups).

The group scripts get passed "$group_name $gid", the user scripts get
passed "$user_name $uid $gid $home_dir".

Eh?

-- 
mterry • Canonical

diff -Nru adduser-3.112/adduser adduser-3.112test1/adduser
--- adduser-3.112/adduser	2009-09-20 16:31:46.000000000 -0400
+++ adduser-3.112test1/adduser	2010-03-16 15:16:19.000000000 -0400
@@ -302,6 +302,9 @@
     my $groupadd = &which('groupadd');
     &systemcall($groupadd, '-g', $new_gid, $new_name);
     &invalidate_nscd("group");
+
+    run_hooks("add-group", $new_name, $new_gid);
+
     print (gtx("Done.\n")) if $verbose;
     exit RET_OK;
 }
@@ -331,6 +334,9 @@
     my $groupadd = &which('groupadd');
     &systemcall($groupadd, '-g', $new_gid, $new_name);
     &invalidate_nscd("group");
+
+    run_hooks("add-group", $new_name, $new_gid);
+
     print (gtx("Done.\n")) if $verbose;
     exit RET_OK;
 }
@@ -460,6 +466,8 @@
     }
     create_homedir (0);
 
+    run_hooks("add-user", $new_name, $new_uid, $new_gid, $home_dir);
+
     exit RET_OK;
 }
 
@@ -616,6 +624,8 @@
 	&systemcall($edquota, '-p', $config{quotauser}, $new_name);
     }
 
+    run_hooks("add-user", $new_name, $new_uid, $new_gid, $home_dir);
+
     &systemcall('/usr/local/sbin/adduser.local', $new_name, $new_uid,
 		$new_gid, $home_dir) if (-x "/usr/local/sbin/adduser.local");
     
diff -Nru adduser-3.112/AdduserCommon.pm adduser-3.112test1/AdduserCommon.pm
--- adduser-3.112/AdduserCommon.pm	2009-09-20 16:31:46.000000000 -0400
+++ adduser-3.112test1/AdduserCommon.pm	2010-03-16 15:15:57.000000000 -0400
@@ -176,6 +176,22 @@
     return 0;
 }
 
+sub run_hooks {
+    my ($hook, @inargs) = @_;
+
+    # Build argument list for run-parts
+    foreach (@inargs) {
+        push(@args, "-a");
+        push(@args, $_);
+    }
+
+    my ($usrhookdir) = "/usr/share/adduser/" . $hook . ".d";
+    &systemcall('/bin/run-parts', @args, $usrhookdir) if (-d $usrhookdir);
+
+    my ($etchookdir) = "/etc/adduser/" . $hook . ".d";
+    &systemcall('/bin/run-parts', @args, $etchookdir) if (-d $etchookdir);
+}
+
 
 # preseed the configuration variables 
 # then read the config file /etc/adduser and overwrite the data hardcoded here
diff -Nru adduser-3.112/debian/rules adduser-3.112test1/debian/rules
--- adduser-3.112/debian/rules	2009-09-20 17:04:55.000000000 -0400
+++ adduser-3.112test1/debian/rules	2010-03-16 15:34:02.000000000 -0400
@@ -73,6 +73,15 @@
 	install -o root -g root -m644 examples/README debian/tmp/usr/share/doc/adduser/examples/
 	install -o root -g root -m644 examples/INSTALL debian/tmp/usr/share/doc/adduser/examples/
 
+	install -o root -g root -d -m755 debian/tmp/usr/share/adduser/add-user.d/
+	install -o root -g root -d -m755 debian/tmp/usr/share/adduser/del-user.d/
+	install -o root -g root -d -m755 debian/tmp/usr/share/adduser/add-group.d/
+	install -o root -g root -d -m755 debian/tmp/usr/share/adduser/del-group.d/
+	install -o root -g root -d -m755 debian/tmp/etc/adduser/add-user.d/
+	install -o root -g root -d -m755 debian/tmp/etc/adduser/del-user.d/
+	install -o root -g root -d -m755 debian/tmp/etc/adduser/add-group.d/
+	install -o root -g root -d -m755 debian/tmp/etc/adduser/del-group.d/
+
 	install -o root -g root -m644 adduser.conf debian/tmp/usr/share/adduser
 	install -o root -g root -m644 debian/copyright debian/tmp/usr/share/doc/adduser/ 
 	install -o root -g root -m644 debian/conffiles debian/tmp/DEBIAN/
diff -Nru adduser-3.112/deluser adduser-3.112test1/deluser
--- adduser-3.112/deluser	2009-12-19 06:00:40.000000000 -0500
+++ adduser-3.112test1/deluser	2010-03-16 15:15:57.000000000 -0400
@@ -364,6 +364,8 @@
     &systemcall($userdel, $user);
     &invalidate_nscd();
 
+    run_hooks("del-user", $user, $pw_uid, $pw_gid, $pw_homedir);
+
     systemcall('/usr/local/sbin/deluser.local', $user, $pw_uid,
                 $pw_gid, $pw_homedir) if (-x "/usr/local/sbin/deluser.local");
 
@@ -404,6 +406,9 @@
     my $groupdel = &which('groupdel');
     &systemcall($groupdel,$group);
     &invalidate_nscd();
+
+    run_hooks("del-group", $group, $gid);
+
     s_print (gtx("Done.\n"));
     exit 0;
 }

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to