[Pkg-shadow-devel] Re: Patch for userdel
Nicolas François
nicolas.francois at centraliens.net
Tue Oct 11 22:53:43 UTC 2005
Resending this mail.
On Tue, Oct 11, 2005 at 09:24:16PM +0200, Nicolas François wrote:
> Hello Thomasz,
>
> Here is a patch for userdel (source and man page).
>
> It documents the -f option, and the removal of the group with the name of
> the deleted user.
>
> It modifies the source so that with -f the group is removed, even if this
> group is still used as a primary group for another user.
> It also removes the usage of MAIL_FILE
>
> Kind Regards,
> --
> Nekral
-------------- next part --------------
Index: man/userdel.8.xml
===================================================================
RCS file: /cvsroot/shadow/man/userdel.8.xml,v
retrieving revision 1.15
diff -u -r1.15 userdel.8.xml
--- man/userdel.8.xml 30 Sep 2005 15:41:20 -0000 1.15
+++ man/userdel.8.xml 11 Oct 2005 19:14:39 -0000
@@ -15,6 +15,7 @@
<cmdsynopsis>
<command>userdel</command>
<arg choice='opt'>-r </arg>
+ <arg choice='opt'>-f </arg>
<arg choice='plain'>
<replaceable>login_name</replaceable>
</arg>
@@ -47,6 +48,31 @@
located in other file systems will have to be searched for and
deleted manually.
</para>
+ <para>
+ The mail spool is defined by the <emphasis>MAIL_DIR</emphasis>
+ variable in the <filename>login.defs</filename> file.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>-f</option>
+ </term>
+ <listitem>
+ <para>
+ This option forces the removal of the user, even if she is
+ still logged in.
+ It also forces <command>userdel</command> to remove the user's
+ home directory or her mail spool, even if another user uses
+ the same home directory or if the mail spool is not owned by
+ the specified user.
+ If <emphasis>USERGROUPS_ENAB</emphasis> is defined to
+ <emphasis remap='I'>yes</emphasis> in
+ <filename>/etc/login.defs</filename> and if a group exists
+ with the same name as the deleted user, then this group will
+ be removed, even if it is still the primary group of another
+ user.
+ </para>
</listitem>
</varlistentry>
</variablelist>
@@ -135,12 +161,21 @@
<refsect1 id='caveats'>
<title>CAVEATS</title>
- <para>
- <command>userdel</command> will not allow you to remove an account if
+ <para><command>userdel</command> will not allow you to remove an account if
the user is currently logged in. You must kill any running processes
- which belong to an account that you are deleting. You may not remove
- any NIS attributes on a NIS client. This must be performed on the NIS
- server.
+ which belong to an account that you are deleting.
+ </para>
+ <para>You may not remove any NIS attributes on a NIS client. This must
+ be performed on the NIS server.
+ </para>
+ <para>If <emphasis>USERGROUPS_ENAB</emphasis> is defined to <emphasis
+ remap='I'>yes</emphasis> in <filename>/etc/login.defs</filename>,
+ <command>userdel</command> will delete the group with the same name
+ as the user. To avoid inconsistencies in the passwd and group
+ databases, <command>userdel</command> will check that this group is
+ not used as a primary group for another user, and will just warn
+ without deleting the user otherwise. The <option>-f</option> option
+ can force the deletion of this group.
</para>
</refsect1>
Index: src/userdel.c
===================================================================
RCS file: /cvsroot/shadow/src/userdel.c,v
retrieving revision 1.52
diff -u -r1.52 userdel.c
--- src/userdel.c 4 Oct 2005 21:05:12 -0000 1.52
+++ src/userdel.c 11 Oct 2005 19:14:39 -0000
@@ -171,6 +171,9 @@
if (grp && getdef_bool ("USERGROUPS_ENAB")
&& (grp->gr_mem[0] == NULL)) {
+ pwd = NULL;
+ if (!fflg)
+ {
/*
* Scan the passwd file to check if this group is still
* used as a primary group.
@@ -188,6 +191,7 @@
}
}
endpwent ();
+ }
if (pwd == NULL) {
/*
@@ -549,7 +553,7 @@
maildir = getdef_str ("MAIL_DIR");
#ifdef MAIL_SPOOL_DIR
- if (!maildir && !getdef_str ("MAIL_FILE"))
+ if (!maildir)
maildir = MAIL_SPOOL_DIR;
#endif
if (!maildir)
More information about the Pkg-shadow-devel
mailing list