Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

@@ -18,10 +18,12 @@
  *
  * CDDL HEADER END
  */
 
 /*
+ * Copyright (c) 2013 Gary Mills
+ *
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */

@@ -137,10 +139,11 @@
 
 #define TRUE    1
 #define FALSE   0
 #define FAILURE -1
 
+#define UT_USER_SZ      32      /* Size of a utmpx ut_user field */
 #define UT_LINE_SZ      32      /* Size of a utmpx ut_line field */
 
 /*
  * SLEEPTIME    The number of seconds "init" sleeps between wakeups if
  *              nothing else requires this "init" wakeup.

@@ -1698,19 +1701,22 @@
                                                 isdigit(cmd->c_id[3])))
                                                     cmd->c_action = M_RESPAWN;
                                         else
                                                     cmd->c_action = M_OFF;
                                 } else {
-                                    for (cmd->c_action = 0, i = 0, *ptr = '\0';
-                                    i < sizeof (actions)/sizeof (char *);
+                                        for (cmd->c_action = 0, i = 0,
+                                            *ptr = '\0';
+                                            i <
+                                            sizeof (actions)/sizeof (char *);
                                     i++) {
                                         if (strcmp(shcmd, actions[i]) == 0) {
                                             if ((cmd->c_levels & MASKSU) &&
                                                 !(act_masks[i] & su_acts))
                                                     cmd->c_action = 0;
                                             else
-                                                cmd->c_action = act_masks[i];
+                                                        cmd->c_action =
+                                                            act_masks[i];
                                             break;
                                         }
                                     }
                                 }
 

@@ -2108,11 +2114,13 @@
                                             (char *)0, glob_envp);
                                         console(B_TRUE,
 "Command\n\"%s\"\n failed to execute.  errno = %d (exec of shell failed)\n",
                                             cmd.c_command, errno);
                                         exit(1);
-                                } else while (waitproc(process) == FAILURE);
+                                } else
+                                        while (waitproc(process) == FAILURE)
+                                                ;
                                 process->p_flags = 0;
                                 st_write();
                         }
                 }
         }

@@ -2806,12 +2814,11 @@
  */
 static char *
 prog_name(char *string)
 {
         char    *ptr, *ptr2;
-        /* XXX - utmp - fix name length */
-        static char word[_POSIX_LOGIN_NAME_MAX];
+        static char word[UT_USER_SZ + 1];
 
         /*
          * Search for the first word skipping leading spaces and tabs.
          */
         while (*string == ' ' || *string == '\t')

@@ -2842,12 +2849,11 @@
 
         /*
          * Copy out up to the size of the "ut_user" array into "word",
          * null terminate it and return a pointer to it.
          */
-        /* XXX - utmp - fix name length */
-        for (ptr2 = &word[0]; ptr2 < &word[_POSIX_LOGIN_NAME_MAX - 1] &&
+        for (ptr2 = &word[0]; ptr2 < &word[UT_USER_SZ] &&
             ptr < string; /* CSTYLED */)
                 *ptr2++ = *ptr++;
 
         *ptr2 = '\0';
         return (&word[0]);

@@ -3805,11 +3811,12 @@
          * On failure we just return because callers of this function check
          * for failure.
          */
         do
                 ptr = realloc(g_state, g_state_sz + delta);
-        while (ptr == NULL && errno == EAGAIN);
+        while (ptr == NULL && errno == EAGAIN)
+                ;
 
         if (ptr != NULL) {
                 /* ensure that the new part is initialized to zero */
                 bzero((caddr_t)ptr + g_state_sz, delta);
 

@@ -3912,17 +3919,19 @@
                 goto new_state;
 
         /* Get the size of the file. */
         do
                 ret = fstat(st_fd, &stb);
-        while (ret == -1 && errno == EINTR);
+        while (ret == -1 && errno == EINTR)
+                ;
         if (ret == -1)
                 goto new_state;
 
         do
                 g_state = malloc(stb.st_size);
-        while (g_state == NULL && errno == EAGAIN);
+        while (g_state == NULL && errno == EAGAIN)
+                ;
         if (g_state == NULL)
                 goto new_state;
 
         to_be_read = stb.st_size;
         ptr = (char *)g_state;

@@ -3964,11 +3973,12 @@
         /* Something went wrong, so allocate new state. */
         g_state_sz = sizeof (struct init_state) +
             ((init_num_proc - 1) * sizeof (struct PROC_TABLE));
         do
                 g_state = calloc(1, g_state_sz);
-        while (g_state == NULL && errno == EAGAIN);
+        while (g_state == NULL && errno == EAGAIN)
+                ;
         if (g_state == NULL) {
                 /* Fatal error! */
                 exit(errno);
         }
 

@@ -4072,11 +4082,12 @@
         char *ioctl_tset_emsg =
             "Couldn't set \"%s\" contract template parameter: %s.\n";
 
         do
                 fd = open64(CTFS_ROOT "/process/template", O_RDWR);
-        while (fd < 0 && errno == EINTR);
+        while (fd < 0 && errno == EINTR)
+                ;
         if (fd < 0) {
                 console(B_TRUE, "Couldn't create process template: %s.\n",
                     strerror(errno));
                 return (-1);
         }

@@ -4169,11 +4180,12 @@
         /*
          * Open an event endpoint.
          */
         do
                 fd = open64(CTFS_ROOT "/process/pbundle", O_RDONLY);
-        while (fd < 0 && errno == EINTR);
+        while (fd < 0 && errno == EINTR)
+                ;
         if (fd < 0) {
                 console(B_TRUE,
                     "Couldn't open process pbundle: %s.  Core smf(5) services "
                     "will not be restarted.\n", strerror(errno));
                 return;

@@ -4202,11 +4214,12 @@
 {
         int fd;
 
         do
                 fd = contract_open(id, "process", name, oflag);
-        while (fd < 0 && errno == EINTR);
+        while (fd < 0 && errno == EINTR)
+                ;
 
         if (fd < 0)
                 console(B_TRUE, "Couldn't open %s for contract %ld: %s.\n",
                     name, id, strerror(errno));