Print this page
Add libuserdefs and use in cmd/{oamuser,passwd}

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/oamuser/user/funcs.c
          +++ new/usr/src/cmd/oamuser/user/funcs.c
↓ open down ↓ 90 lines elided ↑ open up ↑
  91   91          { USERATTR_LOCK_AFTER_RETRIES_KW, check_lock_after_retries,  lock },
  92   92          { USERATTR_CLEARANCE,   check_label,    label },
  93   93          { USERATTR_MINLABEL,    check_label,    label },
  94   94          { USERATTR_IDLECMD_KW,  check_idlecmd,  idlecmd },
  95   95          { USERATTR_IDLETIME_KW, check_idletime, idletime },
  96   96          { USERATTR_AUDIT_FLAGS_KW, check_auditflags, auditflags },
  97   97  };
  98   98  
  99   99  #define NKEYS   (sizeof (keys)/sizeof (ua_key_t))
 100  100  
      101 +/* Import default keys for ordinary useradd */
      102 +void
      103 +import_def(struct userdefs *ud)
      104 +{
      105 +        int i;
      106 +
      107 +        /* Don't import the user type (skip i = 0) */
      108 +        for (i = 1; i < NKEYS; i++) {
      109 +                if (keys[i].newvalue == NULL)
      110 +                        keys[i].newvalue =
      111 +                            userdef_get_by_uakey(ud, keys[i].key);
      112 +        }
      113 +}
      114 +
      115 +/* Export command line keys to defaults for useradd -D */
      116 +void
      117 +update_def(struct userdefs *ud)
      118 +{
      119 +        int i;
      120 +
      121 +        for (i = 0; i < NKEYS; i++) {
      122 +                if (keys[i].newvalue != NULL)
      123 +                        userdef_set_by_uakey(ud, keys[i].key,
      124 +                            keys[i].newvalue);
      125 +        }
      126 +}
      127 +
 101  128  /*
 102  129   * Change a key, there are three different call sequences:
 103  130   *
 104  131   *              key, value      - key with option letter, value.
 105  132   *              NULL, value     - -K key=value option.
 106  133   */
 107  134  
 108  135  void
 109  136  change_key(const char *key, char *value)
 110  137  {
↓ open down ↓ 408 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX