Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Oct 2012 19:30:01 GMT
From:      Eitan Adler <lists@eitanadler.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/172965: pw useradd does not allow -g &quot;&quot;
Message-ID:  <201210271930.q9RJU18K076344@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/172965; it has been noted by GNATS.

From: Eitan Adler <lists@eitanadler.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/172965: pw useradd does not allow -g &quot;&quot;
Date: Sat, 27 Oct 2012 15:20:09 -0400

 ---------- Forwarded message ----------
 From: J B <jb.1234abcd@gmail.com>
 Date: 26 October 2012 15:00
 Subject: Re: misc/172965: pw useradd does not allow -g &quot;&quot;
 To: freebsd-bugs@freebsd.org
 
 
 The following reply was made to PR misc/172965; it has been noted by GNATS.
 
 From: J B <jb.1234abcd@gmail.com>
 To: bug-followup@FreeBSD.org, jeff@bovine.net
 Cc:
 Subject: Re: misc/172965: pw useradd does not allow -g &quot;&quot;
 Date: Fri, 26 Oct 2012 20:58:46 +0200
 
  I am presenting a summary that would suggest better solution.
 
  pw(8):
  ...
  USER OPTIONS
       The following options apply to the useradd and usermod commands:
  ...
       -g group      Set the account's primary group to the given group.  group
                     may be defined by either its name or group number.
  ...
       The useradd command also has the ability to set new user and group
       defaults by using the -D option.  Instead of adding a new user, pw writes
       a new set of defaults to its configuration file, /etc/pw.conf.  When
       using the -D option, you must not use either -n name or -u uid or an
       error will result.  Use of -D changes the meaning of several command line
       switches in the useradd command.  These are:
 
       -D            Set default values in /etc/pw.conf configuration file, or a
                     different named configuration file if the -C config option
                     is used.
  ...
       -g group      Set the default group for new users.  If a blank group is
                     specified using -g "", then new users will be allocated
                     their own private primary group with the same name as their
                     login name.  If a group is supplied, either its name or uid
                     may be given as an argument.
  ...
 
  Now, let's review it once again.
  # pw useradd moo -g moo
  pw: group `moo' does not exist
  # pw useradd moo -g boo
  pw: group `boo' does not exist
  # pw useradd moo -g ""
  pw: group `' is not defined
 
  You want to make a one-time override of any default group as established in
  /etc/pw.conf by "-D -g" options:
  # pw useradd moo -g ""
  moo:*:8007:8007:User &:/home/moo:/bin/sh
 
  But, the below does the same but by checking if user name/id is equal to
  primary group name/id as entered:
  # pw useradd moo -g moo
  moo:*:8007:8007:User &:/home/moo:/bin/sh
  which clearly reflects user's intentions as entered.
  By contrast, your solution is less clear about the user's intentions; also,
  it introduces blank group specification -g "" to entry whose context is
  an immediate and particular account setup, but which is specific to -D -g ""
  type of entry whose context is setting up system defaults for any accounts
  setup.
 _______________________________________________
 freebsd-bugs@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
 To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"
 
 
 -- 
 Eitan Adler



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210271930.q9RJU18K076344>