[LON-CAPA-cvs] cvs: loncom / lcuserdel

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 07 Oct 2002 01:41:31 -0000


foxr		Sun Oct  6 21:41:31 2002 EDT

  Modified files:              
    /loncom	lcuserdel 
  Log:
  Use smbpasswd to delete user, rather than write the file directly.
  
  
  
Index: loncom/lcuserdel
diff -u loncom/lcuserdel:1.12 loncom/lcuserdel:1.13
--- loncom/lcuserdel:1.12	Sun Oct 29 22:37:51 2000
+++ loncom/lcuserdel	Sun Oct  6 21:41:31 2002
@@ -119,14 +119,14 @@
 system('/usr/sbin/groupdel',$safeusername); # ignore error message
 
 # Remove entry from /etc/smbpasswd if it exists
-my $oldsmbpasswd=`/bin/cat /etc/smbpasswd`;
-my $newsmbpasswd=`/bin/grep -v '^${safeusername}:' /etc/smbpasswd`;
-
-if ($oldsmbpasswd ne $newsmbpasswd) {
-    open OUT,">/etc/smbpasswd";
-    print OUT $newsmbpasswd;
-    close OUT;
+#  the safest way to do this is with smbpasswd -x
+#  as that's independent of location of the smbpasswd file.
+#
+if (-e '/usr/bin/smbpasswd') {
+  ($>,$<) = (0,0);		# fool smbpasswd to think this is not setuid.
+  system('/usr/bin/smbpasswd -x '.$safeusername);
 }
+
 
 # Change ownership on directory from username:username to www:www
 # This prevents subsequently added users from having access.