Lines Matching defs:pwd
32 #include <pwd.h>
125 free_passwd(struct passwd *pwd)
127 free(pwd->pw_name);
128 free(pwd->pw_passwd);
129 free(pwd->pw_class);
130 free(pwd->pw_gecos);
131 free(pwd->pw_dir);
132 free(pwd->pw_shell);
136 sdump_passwd(struct passwd *pwd, char *buffer, size_t buflen)
139 pwd->pw_name, pwd->pw_passwd, pwd->pw_uid, pwd->pw_gid,
140 (uintmax_t)pwd->pw_change, pwd->pw_class, pwd->pw_gecos,
141 pwd->pw_dir, pwd->pw_shell, (uintmax_t)pwd->pw_expire,
142 pwd->pw_fields);
146 dump_passwd(struct passwd *pwd)
148 if (pwd != NULL) {
150 sdump_passwd(pwd, buffer, sizeof(buffer));
157 passwd_read_snapshot_func(struct passwd *pwd, char *line)
168 memset(pwd, 0, sizeof(struct passwd));
172 pwd->pw_name = strdup(s);
173 ATF_REQUIRE(pwd->pw_name != NULL);
176 pwd->pw_passwd = strdup(s);
177 ATF_REQUIRE(pwd->pw_passwd != NULL);
180 pwd->pw_uid = (uid_t)strtol(s, &ts, 10);
185 pwd->pw_gid = (gid_t)strtol(s, &ts, 10);
190 pwd->pw_change = (time_t)strtol(s, &ts, 10);
195 pwd->pw_class = strdup(s);
196 ATF_REQUIRE(pwd->pw_class != NULL);
199 pwd->pw_gecos = strdup(s);
200 ATF_REQUIRE(pwd->pw_gecos != NULL);
203 pwd->pw_dir = strdup(s);
204 ATF_REQUIRE(pwd->pw_dir != NULL);
207 pwd->pw_shell = strdup(s);
208 ATF_REQUIRE(pwd->pw_shell != NULL);
211 pwd->pw_expire = (time_t)strtol(s, &ts, 10);
216 pwd->pw_fields = (int)strtol(s, &ts, 10);
228 free_passwd(pwd);
229 memset(pwd, 0, sizeof(struct passwd));
239 struct passwd *pwd;
242 while ((pwd = getpwent()) != NULL) {
243 if (passwd_test_correctness(pwd, NULL) == 0)
244 TEST_DATA_APPEND(passwd, td, pwd);
254 passwd_test_correctness(struct passwd *pwd, void *mdata)
259 dump_passwd(pwd);
262 if (pwd == NULL)
265 if (pwd->pw_name == NULL)
268 if (pwd->pw_passwd == NULL)
271 if (pwd->pw_class == NULL)
274 if (pwd->pw_gecos == NULL)
277 if (pwd->pw_dir == NULL)
280 if (pwd->pw_shell == NULL)
300 passwd_check_ambiguity(struct passwd_test_data *td, struct passwd *pwd)
303 return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd,
310 struct passwd *pwd;
317 pwd = getpwnam(pwd_model->pw_name);
318 if (passwd_test_correctness(pwd, NULL) != 0)
321 if ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
322 (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
341 struct passwd *pwd;
348 pwd = getpwuid(pwd_model->pw_uid);
349 if ((passwd_test_correctness(pwd, NULL) != 0) ||
350 ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
351 (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
366 passwd_test_getpwent(struct passwd *pwd, void *mdata)
370 return (passwd_test_correctness(pwd, NULL));