int main(int argc, char * argv[]) { CFIndex i; CFIndex n; AFPUserList users; struct group * group_ent_p; int count; int start; if (argc < 3) { printf("usage: AFPUsers user_count start\n"); exit(1); } group_ent_p = getgrnam(NETBOOT_GROUP); if (group_ent_p == NULL) { printf("Group '%s' missing\n", NETBOOT_GROUP); exit(1); } count = strtol(argv[1], NULL, 0); if (count < 0 || count > 100) { printf("invalid user_count\n"); exit(1); } start = strtol(argv[2], NULL, 0); if (start <= 0) { printf("invalid start\n"); exit(1); } timestamp_printf("before processing existing users"); AFPUserList_init(&users); timestamp_printf("after processing existing users"); //AFPUserList_print(&users); timestamp_printf("before creating new users"); AFPUserList_create(&users, group_ent_p->gr_gid, start, count); timestamp_printf("after creating new users"); //AFPUserList_print(&users); timestamp_printf("before setting passwords"); n = CFArrayGetCount(users.list); for (i = 0; i < n; i++) { char pass_buf[AFP_PASSWORD_LEN + 1]; AFPUserRef user; user = (AFPUserRef)CFArrayGetValueAtIndex(users.list, i); AFPUser_set_random_password(user, pass_buf, sizeof(pass_buf)); } timestamp_printf("after setting passwords"); printf("Sleeping 1 second\n"); sleep (1); timestamp_printf("before setting passwords again"); n = CFArrayGetCount(users.list); for (i = 0; i < n; i++) { char pass_buf[AFP_PASSWORD_LEN + 1]; AFPUserRef user; user = (AFPUserRef)CFArrayGetValueAtIndex(users.list, i); AFPUser_set_random_password(user, pass_buf, sizeof(pass_buf)); } timestamp_printf("after setting passwords again"); printf("Sleeping 1 second\n"); sleep(1); timestamp_printf("before setting passwords for 3rd time"); for (i = 0; i < n; i++) { char pass_buf[AFP_PASSWORD_LEN + 1]; AFPUserRef user; user = (AFPUserRef)CFArrayGetValueAtIndex(users.list, i); AFPUser_set_random_password(user, pass_buf, sizeof(pass_buf)); } timestamp_printf("after setting passwords for 3rd time"); printf("sleeping %d seconds\n", AFPUSER_PASSWORD_CHANGE_INTERVAL); sleep(AFPUSER_PASSWORD_CHANGE_INTERVAL); timestamp_printf("before setting passwords for second time"); for (i = 0; i < n; i++) { char pass_buf[AFP_PASSWORD_LEN + 1]; AFPUserRef user; user = (AFPUserRef)CFArrayGetValueAtIndex(users.list, i); AFPUser_set_random_password(user, pass_buf, sizeof(pass_buf)); } timestamp_printf("after setting passwords for second time"); AFPUserList_free(&users); printf("sleeping for 60 seconds, run leaks on %d\n", getpid()); sleep(60); exit(0); return (0); }
static __inline__ void S_timestamp(char * msg) { timestamp_printf(msg); }