Changeset 85 in openpam for trunk


Ignore:
Timestamp:
Feb 25, 2002, 5:37:00 PM (18 years ago)
Author:
Dag-Erling Smørgrav
Message:

I was a little quick when I originally wrote this: the code only
supported setting new options. Add support for unsetting options
and changing the value of existing options.

Sponsored by: DARPA, NAI Labs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_set_option.c

    r74 r85  
    7373                        break;
    7474        }
     75        if (value == NULL) {
     76                /* remove */
     77                if (i == cur->optc)
     78                        return (PAM_SUCCESS);
     79                for (free(cur->optv[i]); i < cur->optc; ++i)
     80                        cur->optv[i] = cur->optv[i + 1];
     81                cur->optv[i] = NULL;
     82                return (PAM_SUCCESS);
     83        }
    7584        if ((opt = malloc(len + strlen(value) + 2)) == NULL)
    7685                return (PAM_BUF_ERR);
    7786        sprintf(opt, "%.*s=%s", (int)len, option, value);
    7887        if (i == cur->optc) {
     88                /* add */
    7989                optv = realloc(cur->optv, sizeof(char *) * (cur->optc + 2));
    8090                if (optv == NULL) {
     
    8696                cur->optv = optv;
    8797                ++cur->optc;
     98        } else {
     99                /* replace */
     100                free(cur->optv[i]);
     101                cur->optv[i] = opt;
    88102        }
    89103        return (PAM_SUCCESS);
Note: See TracChangeset for help on using the changeset viewer.