]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_conf.c
Do not expose password if it is empty and PWF_STANDARD format is requested
[pw-darwin.git] / pw / pw_conf.c
index bf93c2a0f25bbd46ca8b2cbd6773edbe4cd92fd7..9377239c990696a7836f392abca7a605b4f5362b 100644 (file)
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- *     $Id: pw_conf.c,v 1.2 1996/12/21 15:35:42 davidn Exp $
  */
 
+#ifndef lint
+static const char rcsid[] =
+  "$FreeBSD$";
+#endif /* not lint */
+
 #include <string.h>
 #include <ctype.h>
 #include <fcntl.h>
 
 #include "pw.h"
-#include "pwupd.h"
 
 #define debugging 0
 
@@ -65,7 +67,8 @@ static char     bourne_shell[] = "sh";
 static char    *system_shells[_UC_MAXSHELLS] =
 {
        bourne_shell,
-       "csh"
+       "csh",
+       "tcsh"
 };
 
 static char const *booltrue[] =
@@ -96,7 +99,8 @@ static struct userconf config =
        1000, 32000,            /* Allowed range of uids */
        1000, 32000,            /* Allowed range of gids */
        0,                      /* Days until account expires */
-       0                       /* Days until password expires */
+       0,                      /* Days until password expires */
+       0                       /* size of default_group array */
 };
 
 static char const *comments[_UC_FIELDS] =
@@ -111,7 +115,7 @@ static char const *comments[_UC_FIELDS] =
        "\n# Log add/change/remove information in this file\n",
        "\n# Root directory in which $HOME directory is created\n",
        "\n# Colon separated list of directories containing valid shells\n",
-       "\n# Space separated list of available shells (without paths)\n",
+       "\n# Comma separated list of available shells (without paths)\n",
        "\n# Default shell (without path)\n",
        "\n# Default group (leave blank for new group per user)\n",
        "\n# Extra groups for new users\n",
@@ -306,7 +310,8 @@ read_userconfig(char const * file)
                                                ? (char *) bourne_shell : newstr(q);
                                        break;
                                case _UC_DEFAULTGROUP:
-                                       config.default_group = (q == NULL || !boolean_val(q, 1) || getgrnam(q) == NULL)
+                                       q = unquote(q);
+                                       config.default_group = (q == NULL || !boolean_val(q, 1) || GETGRNAM(q) == NULL)
                                                ? NULL : newstr(q);
                                        break;
                                case _UC_EXTRAGROUPS:
@@ -415,6 +420,8 @@ write_userconfig(char const * file)
                                        for (j = k = 0; j < _UC_MAXSHELLS && system_shells[j] != NULL; j++) {
                                                char    lbuf[64];
                                                int     l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", system_shells[j]);
+                                               if (l < 0)
+                                                       l = 0;
                                                if (l + k + 1 < len || extendline(&buf, &len, len + LNBUFSZ) != -1) {
                                                        strcpy(buf + k, lbuf);
                                                        k += l;
@@ -433,6 +440,8 @@ write_userconfig(char const * file)
                                        for (j = k = 0; j < config.numgroups && config.groups[j] != NULL; j++) {
                                                char    lbuf[64];
                                                int     l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", config.groups[j]);
+                                               if (l < 0)
+                                                       l = 0;
                                                if (l + k + 1 < len || extendline(&buf, &len, len + 1024) != -1) {
                                                        strcpy(buf + k, lbuf);
                                                        k +=  l;