char * getusername(void) { static char username[128] = "???"; if (username[0] == '?') { char *logname = getenv("LOGNAME"); if (logname) { strncpy(username, logname, 128); username[127] = 0x00; } } if (username[0] == '?') { struct passwd *pw = getuserinfo(); if (pw) { strncpy(username, getuserinfo() -> pw_name, sizeof(username)); username[sizeof(username) - 1] = 0x00; } } return username; }
void load_configfile_wrapper(char *config_file) { /* load configurationfile (if any) */ if (load_global_config) do_load_config(-1, NULL, CONFIG_FILE); if (config_file) { do_load_config(-1, NULL, config_file); } else { int path_max = find_path_max(); char *path = mymalloc(path_max + 1); char *home = getenv("HOME"); struct passwd *pp = getuserinfo(); if (home) snprintf(path, path_max, "%s/.multitailrc", home); else snprintf(path, path_max, "%s/.multitailrc", pp -> pw_dir); do_load_config(-1, NULL, path); myfree(path); } }
void mf_name(int num, JSMemberfield* field) { char userinfo[MAX_STRING_CHARS]; getuserinfo(num, userinfo, sizeof(userinfo)); char* name = Info_ValueForKey(userinfo, "name"); duk_push_string(ctx, name); }
void addchild(formfield *fields, int count) { formfield *pname, *ppasswd, *name, *passwd1, *passwd2, *dispname, *email, *ref; char pdispname[30]; char pimgfile[30]; char sref[100]; pname=findfield("pname",fields,count); ppasswd=findfield("ppasswd",fields,count); name=findfield("name",fields,count); passwd1=findfield("passwd1",fields,count); passwd2=findfield("passwd2",fields,count); dispname=findfield("dispname",fields,count); email=findfield("email",fields,count); ref=findfield("ref",fields,count); if((pname==NULL) || (ppasswd==NULL) || (name==NULL) || (passwd1==NULL) || (passwd2==NULL) || (dispname==NULL) || (email==NULL) || (ref==NULL)) { printf("wrong format\n"); return; } if(!getuserinfo(pname->data, ppasswd->data, pdispname, pimgfile)) { printf("invalid parent account. . . (check username and password)\n"); return; } if(userexist(name->data)) { printf("the username was taken. . . please try again\n"); return; } if(verifyinfo(name->data, passwd1->data, passwd2->data, dispname->data, email->data, pname->data)) { sprintf(sref,"%s(invt=%s)",ref->data,pname->data); adduserinfo(name->data, passwd1->data, dispname->data, "", email->data, sref); printf("your account has been added to the system under the invitation of %s. it is activated and you can use it now. <a href=\"index.html\">[return to webboard]</a>\n", pdispname); } }
bool authpgsql_connection::getuserinfo(authpgsql_userinfo &uiret, const char *username, const char *service) { std::string querybuf; if (!do_connect()) return false; if (config_file.select_clause.empty()) { std::ostringstream o; o << "SELECT " << config_file.login_field << ", " << config_file.crypt_field << ", " << config_file.clear_field << ", " << config_file.uid_field << ", " << config_file.gid_field << ", " << config_file.home_field << ", " << (strcmp(service, "courier") == 0 ? config_file.defaultdelivery_field :config_file.maildir_field) << ", " << config_file.quota_field << ", " << config_file.name_field << ", " << config_file.options_field << " FROM " << config_file.user_table << " WHERE " << config_file.login_field << " = '" << escape_username(username) << "' AND (" << config_file.where_clause << ")"; querybuf=o.str(); } else { std::map<std::string, std::string> parameters; parameters["service"]=service; querybuf=config_file .parse_custom_query(config_file.select_clause, escape(username), config_file.defdomain, parameters); } DPRINTF("SQL query: %s", querybuf.c_str()); result res1(*this, querybuf); if (res1) return getuserinfo(uiret, res1); disconnect(); if (do_connect()) { result res2(*this, querybuf); if (res2) return getuserinfo(uiret, res2); } return false; }