void string_input_popup::edit( std::string &value ) { only_digits( false ); text( value ); query(); if( !canceled() ) { value = text(); } }
void string_input_popup::edit( int &value ) { only_digits( true ); text( to_string( value ) ); query(); if( !canceled() ) { value = std::atoi( text().c_str() ); } }
// multi kick void m_kick () { int i, k; gedict_t *p; char arg_x[1024], *str; int argc = trap_CmdArgc(); if( !is_adm( self ) ) { G_sprint(self, 2, "You are not an admin\n"); return; } trap_CmdArgv( 1, arg_x, sizeof( arg_x ) ); if ( argc < 2 || !only_digits(arg_x) ) { G_sprint(self, 2, "mkick <id1 [id2 [id3 ...]] [reason]>\n"); return; } for ( k = 0, i = 1; i < argc; i++ ) { trap_CmdArgv( i, arg_x, sizeof( arg_x ) ); if ( !only_digits(arg_x) ) break; if ( !(p = SpecPlayer_by_id( atoi(arg_x) )) && !(p = not_connected_by_id( atoi(arg_x) )) ) { G_sprint(self, 2, "mkick: client %s not found\n", arg_x); continue; } if( !DoKick( p, self ) ) continue; k++; } if ( !k ) return; if ( !strnull( str = params_str(i, -1) ) ) // show reason G_bprint(2, "\x90%s\x91\n", str); }
// Init unix related stuff. // Daemon, chroot, setgid and setuid code (-d, -t, -g, -u) // was copied from bind (DNS server) sources. static void SV_System_Init(void) { int j; qbool ind; uid_t user_id = 0; gid_t group_id = 0; struct passwd *pw = NULL; struct group *gr; char *user_name = NULL, *group_name = NULL, *chroot_dir; // daemon if (COM_CheckParm ("-d")) { switch (fork()) { case -1: exit(-1); // Error, do normal exit(). case 0: break; // Child, continue process. default: _exit(0); // Parent, for some reason we prefer here "limited" clean up with _exit(). } if (setsid() == -1) Sys_Printf("setsid: %s\n", strerror(qerrno)); if ((j = open(_PATH_DEVNULL, O_RDWR)) != -1) { (void)dup2(j, STDIN_FILENO); (void)dup2(j, STDOUT_FILENO); (void)dup2(j, STDERR_FILENO); if (j > 2) (void)close(j); //isdaemon = true; do_stdin = false; } } // setgid j = COM_CheckParm ("-g"); if (j && j + 1 < com_argc) { ind = true; group_name = com_argv[j + 1]; if (only_digits(group_name)) group_id = Q_atoi(group_name); else { if (!(gr = getgrnam(group_name))) { Sys_Printf("WARNING: group \"%s\" unknown\n", group_name); ind = false; } else group_id = gr->gr_gid; } if (ind) if (setgid(group_id) < 0) Sys_Printf("WARNING: Can't setgid to group \"%s\": %s\n", group_name, strerror(qerrno)); } // setuid - only resolve name ind = false; j = COM_CheckParm ("-u"); if (j && j + 1 < com_argc) { ind = true; user_name = com_argv[j + 1]; j = only_digits(user_name); if (j) { user_id = Q_atoi(user_name); pw = getpwuid(user_id); } if (!j || !pw) { if (!(pw = getpwnam(user_name))) { if (j) Sys_Printf("WARNING: user with uid %u unknown, but we will try to setuid\n", (unsigned)user_id); else { Sys_Printf("WARNING: user \"%s\" unknown\n", user_name); ind = false; } } else user_id = pw->pw_uid; } if (ind) { if (pw) { if (!group_name) { group_id = pw->pw_gid; if (setgid(group_id) < 0) Sys_Printf("WARNING: Can't setgid to group \"%s\": %s\n", group_name, strerror(qerrno)); } if (!getuid() && initgroups(pw->pw_name, group_id) < 0) Sys_Printf("WARNING: Can't initgroups(%s, %d): %s", user_name, (unsigned)group_id, strerror(qerrno)); } } } // chroot j = COM_CheckParm ("-t"); if (j && j + 1 < com_argc) { chroot_dir = com_argv[j + 1]; if (chroot(chroot_dir) < 0) Sys_Printf("chroot %s failed: %s\n", chroot_dir, strerror(qerrno)); else if (chdir("/") < 0) Sys_Printf("chdir(\"/\") to %s failed: %s\n", chroot_dir, strerror(qerrno)); } // setuid - we can't setuid before chroot and // can't resolve uid/gid from user/group names after chroot if (ind) { if (setuid(user_id) < 0) Sys_Printf("WARNING: Can't setuid to user \"%s\": %s\n", user_name, strerror(qerrno)); } }