void suh::set_user_detail(const std::string& user, const std::string& detail, const std::string& value) { if(detail == "mail") { set_mail(user, value); } else if (detail == "password") { set_password(user, value); } else if (detail == "realname") { set_realname(user, value); } else { throw error("Invalid usersdetail '" + detail + "'. Valid details are: " + get_valid_details()); } }
static int get_username_info (void) { char *name = NULL; #if HAS_PASSWORD_CODE struct passwd *pw; #endif #if HAS_PASSWORD_CODE /* I cannot use getlogin under Unix because some implementations * truncate the username to 8 characters. Besides, I suspect that * it is equivalent to the following line. */ /* The man page for getpwuid indicate that the pointer _may_ be to a static * area. So, there is nothing to free here. */ pw = getpwuid (getuid ()); if (pw != NULL) name = pw->pw_name; #endif if (((name == NULL) || (*name == 0)) && ((name = getenv("USER")) == NULL) && ((name = getenv("LOGNAME")) == NULL)) name = "unknown"; if (-1 == set_username (name)) return -1; name = getenv ("NAME"); #if HAS_PASSWORD_CODE if ((name == NULL) && (pw != NULL) && (pw->pw_gecos != NULL)) name = pw->pw_gecos; #endif if (name == NULL) name = ""; if (-1 == set_realname (name)) return -1; return 0; }
static void set_realname_cmd (char *s) { (void) set_realname (s); }