int generate_complex_passwd( char passwd[] ){ /* generate a passwd stored it in passwd[] ** return 1 if generate suitable string, like:vf^*0Wu4gT ** return 0 if generate simple string, like:BfFicK5X8vS */
/* store username to single linked list in 2 files */ userinfo_root = load_file_userinfo( userinfo_file ); apacheauth_root = load_file_apacheauth( apache_auth_file );
/* compare the 2 files to find any error in files and log it */ apacheauth *j; userinfo *i; for( j=apacheauth_root; j; j=j->next ){ for(i=userinfo_root; i; i=i->next){ if( !strcmp(i->username,j->username) ) break; } if( i == NULL ){ fprintf( fp_error,"%s in file %s, but not in file %s , must modify by hand !\n", j->username,apache_auth_file,userinfo_file ); fflush(fp_error); }
}
for(i=userinfo_root; i; i=i->next){ for( j=apacheauth_root; j; j=j->next ){ if( !strcmp(i->username,j->username) ) break; } if( j == NULL ){ i->modify_pass = 0; fprintf( fp_error,"%s in file %s, but not in file %s , can not modify his passwd !\n", i->username,userinfo_file,apache_auth_file ); fflush(fp_error); }