/* 使用者管理 */ int m_user(void) { userec_t xuser; int id; char genbuf[200]; vs_hdr("使用者設定"); usercomplete(msg_uid, genbuf); if (*genbuf) { move(2, 0); if ((id = getuser(genbuf, &xuser))) { user_display(&xuser, 1); if( HasUserPerm(PERM_ACCOUNTS) ) uinfo_query(xuser.userid, 1, id); else pressanykey(); } else { outs(err_uid); clrtoeol(); pressanykey(); } } return 0; }
//取得genbuf中保存的用户所在的记录位置到*id中,为零表示不存在 int gettheuserid(int x, char *title, int *id) { screen_move(x, 0); usercomplete(title, genbuf); if (*genbuf == '\0') { screen_clear(); return 0; } if (!(*id = getuser(genbuf))) { screen_move_clear(x + 3); //% prints("错误的使用者代号"); prints("\xb4\xed\xce\xf3\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf\xb4\xfa\xba\xc5"); pressreturn(); screen_clear(); return 0; } return 1; }
OM_uint32 GSSAPI_LIB_FUNCTION gss_acquire_cred_ex_f(gss_status_id_t status, gss_name_t desired_name, OM_uint32 flags, OM_uint32 time_req, gss_const_OID desired_mech, gss_cred_usage_t cred_usage, gss_auth_identity_t identity, void * userctx, void (*usercomplete)(void *, OM_uint32, gss_status_id_t, gss_cred_id_t, gss_OID_set, OM_uint32)) { OM_uint32 major_status, minor_status; gss_name_t name = GSS_C_NO_NAME; gss_cred_id_t cred; OM_uint32 junk; gss_buffer_desc buffer; if (usercomplete == NULL) return GSS_S_CALL_INACCESSIBLE_READ; /* * If no desired_name, make one up from the identity */ if (desired_name == GSS_C_NO_NAME) { char *str; if (identity->username == NULL) return GSS_S_FAILURE; if (identity->realm) asprintf(&str, "%s@%s", identity->username, identity->realm); else str = strdup(identity->username); buffer.value = str; buffer.length = strlen(str); major_status = gss_import_name(&minor_status, &buffer, GSS_C_NT_USER_NAME, &name); free(str); if (major_status) return major_status; desired_name = name; } /* * First make sure that at least one of the requested * mechanisms is one that we support. */ if (desired_mech) { int t; gss_test_oid_set_member(&junk, desired_mech, _gss_mech_oids, &t); if (!t) { if (name) gss_release_name(&junk, &name); return (GSS_S_BAD_MECH); } } buffer.value = identity->password; buffer.length = strlen(identity->password); cred = GSS_C_NO_CREDENTIAL; major_status = gss_acquire_cred_ext(&minor_status, desired_name, GSS_C_CRED_PASSWORD, &buffer, time_req, desired_mech, cred_usage, &cred); if (name) gss_release_name(&junk, &name); if (major_status) return major_status; usercomplete(userctx, major_status, status, cred, GSS_C_NO_OID_SET, GSS_C_INDEFINITE); return GSS_S_COMPLETE; }
int kick_user( struct user_info *userinfo ) { int id, ind; struct user_info uin; struct userec kuinfo; char kickuser[40], buffer[40]; if (uinfo.mode != LUSERS && uinfo.mode != OFFLINE && uinfo.mode != FRIEND) { modify_user_mode(ADMIN); stand_title("踢使用者下站"); move(1, 0); usercomplete("输入使用者帐号: ", kickuser); if (*kickuser == '\0') { clear(); return 0; } if (!(id = getuser(kickuser))) { move(3, 0); prints("无效的用户 ID!"); clrtoeol(); pressreturn(); clear(); return 0; } move(1, 0); clrtoeol(); sprintf(genbuf,"踢掉使用者 : [%s].", kickuser); move(2, 0); if (askyn(genbuf, NA, NA) == NA) { move(2, 0); prints("取消踢使用者..\n"); pressreturn(); clear(); return 0; } search_record(PASSFILE, &kuinfo, sizeof(kuinfo), cmpuids, kickuser); ind = search_ulist(&uin, t_cmpuids, id); } else { uin = *userinfo; strcpy(kickuser, uin.userid); ind = YEA; } if (!ind||!uin.active||(uin.pid && kill(uin.pid, 0)==-1)) { if(uinfo.mode!=LUSERS&&uinfo.mode!=OFFLINE&&uinfo.mode!=FRIEND) { move(3, 0); prints("用户 [%s] 不在线上",kickuser); clrtoeol(); pressreturn(); clear(); } return 0; } kill(uin.pid, SIGHUP); //sprintf(buffer, "kicked %s", kickuser); //report(buffer); if(strcmp(currentuser.userid , kickuser)) { char secu[STRLEN]; sprintf(secu, "将用户[%s]踢下站", kickuser); securityreport(secu); } sprintf(genbuf, "%s (%s)", kuinfo.userid, kuinfo.username); log_usies("KICK ", genbuf); move(2, 0); if(uinfo.mode!=LUSERS&&uinfo.mode!=OFFLINE&&uinfo.mode!=FRIEND) { prints("用户 [%s] 已经被踢下站.\n",kickuser); pressreturn(); clear(); } return 1; }
int addressbook() { char str[STRLEN], buf[STRLEN], filename[STRLEN], items[NADDRESSITEM][STRLEN]; int i; modify_user_mode(ADDRESSBOOK); while (1) { move(0, 0); clrtobot(); getdata(0, 0, "(A)查询通讯录 (B)设置通讯录 (Q)离开 [Q]: ", buf, 3, DOECHO, YEA); switch (buf[0]) { case 'A': case 'a': usercomplete("请输入使用者代号: ", buf); if (!buf[0]) continue; prints("%s的通讯录内容如下\n", buf); prints("=================================\n"); sethomefile(filename, buf, "addressbook"); if (!dashf(filename)) { prints("该用户尚未设置通讯录"); pressanykey(); continue; } prints("项目 内容\n"); readaddressbook(filename, items); move(5, 0); clrtobot(); showaddressbook(items, addressbookmode(currentuser->userid, buf)); pressanykey(); break; case 'B': case 'b': sethomefile(filename, currentuser->userid, "addressbook"); readaddressbook(filename, items); prints("编辑通讯录(\033[1;31m小心被滥用\033[m)\n"); prints("=================================\n"); prints("项目 公开级别 内容\n"); for (i = 0; i < NADDRESSITEM; i++) { move(4, 0); clrtobot(); showaddressbook(items, -1); move(NADDRESSITEM + 4, 0); prints("=================================\n"); showaddressitem(items[i], i, -1); sprintf(str, "%s: ", addressitems[i]); getdata(NADDRESSITEM + 5, 0, str, items[i] + 1, 60, DOECHO, items[i][0] ? NA : YEA); if (items[i][0] < '0' || items[i][0] > '3') items[i][0] = '3'; sprintf(buf, "公开级别 (0)所有人 (1)与我为友者 (2)我的好友 (3)不公开 [%c]", items[i][0]); if (items[i][1]) getdata(NADDRESSITEM + 6, 0, buf, str, 3, DOECHO, YEA); if (str[0] < '0' || str[0] > '3') str[0] = items[i][0]; items[i][0] = str[0]; } move(3, 0); clrtobot(); showaddressbook(items, 1); prints("=================================\n"); getdata(NADDRESSITEM + 5, 0, "以上资料是否正确, 按 Q 放弃 (Y/Quit)? [Y]:", str, 3, DOECHO, YEA); if (str[0] != 'Q' || str[0] == 'q') saveaddressbook(filename, items); break; default: return FULLUPDATE; } } }