version 1.1.2.6, 2012/09/19 12:23:12
|
version 1.1.2.9, 2012/09/19 13:30:46
|
Line 68 int main()
|
Line 68 int main()
|
u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, ""); |
u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, ""); |
printf("cfg_getPasswd %p NAME \"\"\n", u); |
printf("cfg_getPasswd %p NAME \"\"\n", u); |
|
|
#if 0 | printf("\n----------\n"); |
| |
/* unit test set */ |
/* unit test set */ |
printf("attr=%d set %d NULL\n", ALL, pwd_SetAttribute(&db, ALL, NULL)); | printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 4, "use", "alabala", 101, 4, |
printf("attr=%d set %d w/ empty\n", ALL, pwd_SetAttribute(&db, ALL, ddd)); | NULL, 0, 0, NULL, NULL, NULL)); |
pwdSetValue(&ddd, ALL, "use"); | printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 3, "use", "alabala", 101, 3, |
pwdSetValue(&ddd, Password, "alabala"); | NULL, 0, 0, NULL, NULL, NULL)); |
pwdSetValue(&ddd, UID, "101"); | printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 3, "user_l", "pliok", 999, 3, |
pwdGetValue(ddd, Password, str, 256); | NULL, 0, 0, NULL, NULL, NULL)); |
printf("attr=%d set %d use getvalue=%s\n", ALL, pwd_SetAttribute(&db, ALL, ddd), str); | printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 2, "use1", "WC_00", 0, 0, |
pwdFreeValue(&ddd, ALL); | NULL, 0, 0, NULL, NULL, NULL)); |
| printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 0, "USE1", "WC_00", 10000, 20, |
| NULL, 0, 0, "TEST for use", "/home/USE1", "/bin/sh")); |
| printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 0, "USE2", "WC_!!", 10001, 20, |
| NULL, 0, 0, "TEST for use", "/home/USE2", NULL)); |
|
|
pwdSetValue(&ddd, ALL, "user_l"); | printf("\n----------\n"); |
pwdSetValue(&ddd, UID, "999"); | |
pwdSetValue(&ddd, Password, "pliok"); | |
pwdGetValue(ddd, Username, str, 256); | |
printf("attr=%d %s db=%p ddd=%p set %d\n", ALL, str, db, ddd, pwd_SetAttribute(&db, ALL, ddd)); | |
pwdSetValue(&ddd, Username, "use"); | |
pwdSetValue(&ddd, Password, "WC_00"); | |
printf("2.attr=%d %s db=%p ddd=%p set %d\n", Password, str, db, ddd, pwd_SetAttribute(&db, Password, ddd)); | |
printf("get fail.attr=%d %s db=%p ddd=%p set %d\n", Password, str, db, ddd, pwd_GetAttribute(db, Password, ddd)); | |
pwdFreeValue(&ddd, ALL); | |
/* unit end set */ | |
/* unit test get */ | |
pwdSetValue(&ddd, ALL, "user_l"); | |
printf("GET attr=%d %s db=%p ddd=%p set %d\n", Password, ddd->psPass, db, ddd, pwd_GetAttribute(db, Password, ddd)); | |
pwdFreeValue(&ddd, ALL); | |
/* unit end set */ | |
|
|
/* unit test unset */ |
/* unit test unset */ |
pwdSetValue(&ddd, ALL, "ttt"); | u = (struct tagUser*) cfg_getPasswd(&db, PWD_CRIT_NAME, "ttt"); |
printf("attr=%d Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, ddd->psUser)); | printf("-> user=%s %u:%u \"%s\"\n", AIT_GET_STR(&u->usr_name), |
printf("UNset attr=%d %s db=%p ddd=%p set %d\n", Class, ddd->psClass, db, ddd, pwd_UnsetAttribute(&db, Class, ddd)); | AIT_GET_LIKE(&u->usr_uid, u_int), AIT_GET_LIKE(&u->usr_gid, u_int), |
printf("UNset attr=%d %s db=%p ddd=%p set %d\n", Password, ddd->psPass, db, ddd, pwd_UnsetAttribute(&db, Password, ddd)); | AIT_GET_LIKE(&u->usr_realm, char*)); |
pwdFreeValue(&ddd, ALL); | printf("unset %p\n", cfg_unsetPasswd(&db, PWD_CRIT_NAME, "ttt")); |
pwdSetValue(&ddd, ALL, "aa"); | printf("unset %p\n", cfg_unsetPasswd(&db, PWD_CRIT_NAME, "tttZZZ")); |
printf("UNset attr=%d %s db=%p ddd=%p set %d\n", ALL, ddd->psUser, db, ddd, pwd_UnsetAttribute(&db, ALL, ddd)); | printf("unset %p\n", cfg_unsetPasswd(&db, PWD_CRIT_NAME, "ttt")); |
pwdFreeValue(&ddd, ALL); | |
/* unit end unset */ | |
printf("ALL el. Count of array %d w/ NULL \n", pwd_FindAttribute(db, ALL, NULL)); | |
|
|
WritePasswd(stdout, &db); | cfgWritePasswd(stdout, &db); |
|
|
|
printf("\n----------\n"); |
|
|
|
#if 0 |
pwdSetValue(&ddd, ALL, "user_l"); |
pwdSetValue(&ddd, ALL, "user_l"); |
pwdSetValue(&ddd, Password, "000"); |
pwdSetValue(&ddd, Password, "000"); |
switch ((ret = pwd_Authenticate(db, ddd))) { |
switch ((ret = pwd_Authenticate(db, ddd))) { |
Line 123 int main()
|
Line 113 int main()
|
printf("Access granted - user found at position %d\n", ret); |
printf("Access granted - user found at position %d\n", ret); |
} |
} |
pwdFreeValue(&ddd, ALL); |
pwdFreeValue(&ddd, ALL); |
|
#endif |
|
|
if (CreatePasswd("test4e.pwd", &db)) { | if (cfgCreatePasswd("test4e.pwd", &db)) { |
printf("Error #%d - %s\n", pwd_GetErrno(), pwd_GetError()); | printf("Error #%d - %s\n", cfg_GetErrno(), cfg_GetError()); |
return 2; |
return 2; |
} |
} |
#endif |
|
|
|
cfgUnloadPasswd(&db); |
cfgUnloadPasswd(&db); |
return 0; |
return 0; |