Exemplo n.º 1
1
Arquivo: cpu-bl.c Projeto: npe9/harvey
/*
 *  user level challenge/response
 */
static int
netkeyauth(int fd)
{
	char chall[32];
	char resp[32];

	strecpy(chall, chall+sizeof chall, getuser());
	print("user[%s]: ", chall);
	if(readln(resp, sizeof(resp)) < 0)
		return -1;
	if(*resp != 0)
		strcpy(chall, resp);
	writestr(fd, chall, "challenge/response", 1);

	for(;;){
		if(readstr(fd, chall, sizeof chall) < 0)
			break;
		if(*chall == 0)
			return fd;
		print("challenge: %s\nresponse: ", chall);
		if(readln(resp, sizeof(resp)) < 0)
			break;
		writestr(fd, resp, "challenge/response", 1);
	}
	return -1;
}
Exemplo n.º 2
0
int
main(int argc, char ** argv)
{
    struct userec *user = NULL;

    chdir(BBSHOME);
    resolve_ucache();
    resolve_boards();
    if (argc == 2 && !strcmp(argv[1], "-a"))
        apply_users(query_BM, NULL);
    else if (argc == 3 && !strcmp(argv[1], "-u"))
    {
        getuser(argv[2], &user);
        if (user == NULL)
        {
            fprintf(stderr, "User %s not found.\n", argv[1]);
            return -1;
        }
        user->usedspace = 0xFFFF;
    }
    else if (argc == 3 && !strcmp(argv[1], "-s"))
    {
        getuser(argv[2], &user);
        if (user == NULL)
        {
            fprintf(stderr, "User %s not found.\n", argv[1]);
            return -1;
        }
        printf("User %s usedspace: %u bytes.\n", user->userid, user->usedspace);
    }	else
        usage();

    return 0;
}
Exemplo n.º 3
0
Arquivo: miscd.c Projeto: wyat/kbs
int killauser(struct userec *theuser, void *data)
{
    int a;
    struct userec *ft,copyuser;

    if (!theuser || theuser->userid[0] == 0)
        return 0;
    memcpy(&copyuser,theuser,sizeof(copyuser));

    if (id_invalid(copyuser.userid))
        return 0;

    a = compute_user_value(&copyuser);

    if ((a <= 0)&&strcmp(copyuser.userid,"guest")) {
        newbbslog(BBSLOG_USIES, "kill user %s", copyuser.userid);
        kick_user_utmp(getuser(copyuser.userid, NULL), NULL, SIGKILL);
        a = getuser(copyuser.userid, &ft);
        setmailpath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sethomepath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sprintf(genbuf1, "/bin/rm -fr tmp/email/%s", copyuser.userid);
        system(genbuf1);
        setuserid2(a, "");
        theuser->userlevel = 0;
        /*strcpy(theuser->address, "");*/
        strcpy(theuser->username, "");
        /*strcpy(theuser->realname, "");*/
    }

    return 0;
}
Exemplo n.º 4
0
CFsys*
fsamount(int fd, char *aname)
{
	CFid *afid, *fid;
	AuthInfo *ai;
	CFsys *fs;
	
	fs = fsinit(fd);
	if(fs == nil)
		return nil;
	if((afid = fsauth(fs, getuser(), aname)) == nil)
		goto noauth;
	ai = fsauth_proxy(afid, amount_getkey, "proto=p9any role=client");
	if(ai != nil)
		auth_freeAI(ai);
noauth:
	fid = fsattach(fs, afid, getuser(), aname);
	fsclose(afid);
	if(fid == nil){
		_fsunmount(fs);
		return nil;
	}
	fssetroot(fs, fid);
	return fs;
}
Exemplo n.º 5
0
int main()
{
        struct fileheader *x;
        char board[80], file[80], target[80];
        init_all();
        strsncpy(board, getparm("board"), 30);
        strsncpy(file, getparm("file"), 30);
        strsncpy(target, getparm("target"), 30);
        if(!loginok)
                http_fatal("匆匆过客不能进行本项操作");
        if(!has_read_perm(&currentuser, board))
                http_fatal("错误的讨论区");
        x=get_file_ent(board, file);
        if(x==0)
                http_fatal("错误的文件名");
        printf("<center>%s -- 转寄/推荐给好友 [使用者: %s]<hr color=green>\n", BBSNAME, currentuser.userid);
        if(target[0]) {
                if(!strstr(target, "@")) {
                        if(!getuser(target))
                                http_fatal("错误的使用者帐号");
                        strcpy(target, getuser(target)->userid);
                }
                return do_fwd(x, board, target);
        }
        printf("<table><tr><td>\n");
        printf("文章标题: %s<br>\n", nohtml(x->title));
        printf("文章作者: %s<br>\n", x->owner);
        printf("原讨论区: %s<br>\n", board);
        printf("<form action=bbsfwd method=post>\n");
        printf("<input type=hidden name=board value=%s>", board);
        printf("<input type=hidden name=file value=%s>", file);
        printf("把文章转寄给 <input name=target size=30 maxlength=30 value=%s> (请输入对方的id或email地址). <br>\n",
               currentuser.email);
        printf("<input type=submit value=确定转寄></form>");
}
Exemplo n.º 6
0
static SmbProcessResult
netwkstagetinfo(SmbBuffer *inparam, SmbBuffer *outparam, SmbBuffer *outdata)
{
	uint16_t level;
	uint16_t usefulbytes;
	SmbProcessResult pr;
	int moredata;

	/* WrLh
	 * ushort sLevel, RCVBUF pbBuffer, RCVBUFLEN cbBuffer, ushort *pcbTotalAvail
	*/

	if (!smbbuffergets(inparam, &level)) {
	fmtfail:
		pr = SmbProcessResultFormat;
		goto done;
	}
	
	smblogprintif(smbglobals.log.rap2, "netwkstagetinfo(%lud, %lud)\n",
		level, smbbufferwritespace(outdata));

	if (level != 10)
		goto fmtfail;

	usefulbytes = 22 + smbstrlen(smbglobals.serverinfo.name) + smbstrlen(getuser())
		+ 3 * smbstrlen(smbglobals.primarydomain);

	moredata = usefulbytes > smbbufferwritespace(outdata);

	assert(smbbufferputl(outdata, 0));
	assert(smbbufferputl(outdata, 0));
	assert(smbbufferputl(outdata, 0));
	assert(smbbufferputb(outdata, smbglobals.serverinfo.vmaj));
	assert(smbbufferputb(outdata, smbglobals.serverinfo.vmin));
	assert(smbbufferputl(outdata, 0));
	assert(smbbufferputl(outdata, 0));
	assert(smbbufferfixupabsolutel(outdata, 0));
	assert(smbbufferputstring(outdata, nil, SMB_STRING_ASCII, smbglobals.serverinfo.name));
	assert(smbbufferfixupabsolutel(outdata, 4));
	assert(smbbufferputstring(outdata, nil, SMB_STRING_ASCII, getuser()));
	assert(smbbufferfixupabsolutel(outdata, 8));
	assert(smbbufferputstring(outdata, nil, SMB_STRING_ASCII, smbglobals.primarydomain));
	assert(smbbufferfixupabsolutel(outdata, 14));
	assert(smbbufferputstring(outdata, nil, SMB_STRING_ASCII, smbglobals.primarydomain));
	assert(smbbufferfixupabsolutel(outdata, 18));
	assert(smbbufferputstring(outdata, nil, SMB_STRING_ASCII, smbglobals.primarydomain));

	if (!smbbufferputs(outparam, moredata ? SMB_RAP_ERROR_MORE_DATA : SMB_RAP_NERR_SUCCESS)
		|| !smbbufferputs(outparam, 0)
		|| !smbbufferputs(outparam, usefulbytes)) {
		pr = SmbProcessResultFormat;
		goto done;
	}
	
	pr = SmbProcessResultReply;
			
done:
	return pr;
}
Exemplo n.º 7
0
void
showmyblog()
{
	struct userec *x;
	if (loginok && !isguest &&
			getuser(currentuser->userid, &x) && x->hasblog) 
	{
		printf(" <a href=blog?U=%d target=f3>我的Blog</a> ",
				getuser(currentuser->userid, NULL));
	}
	else
	{
		printf(" <a href=blogpage target=f3>Blog社区</a> ");
	}
}
Exemplo n.º 8
0
int dosearchuser(char *userid) {
    if((usernum = getuser(userid)))
	memcpy(&cuser, &xuser, sizeof(cuser));
    else
	memset(&cuser, 0, sizeof(cuser));
    return usernum;
}
Exemplo n.º 9
0
// username�û���֤ʧ�ܵĴ�����������û�������Ŀǰ��δʹ������������� added by interma@BMY 2005.5.16
void register_fail(char *userid)
{
	int id;
	strcpy(genbuf, userid);
	id = getuser(genbuf);

	if (lookupuser.userid[0] == '\0' || !strcmp(lookupuser.userid, "SYSOP")) {
		return;
	}

	sprintf(genbuf, "mail/%c/%s", mytoupper(lookupuser.userid[0]),
		lookupuser.userid);
	deltree(genbuf);
	sprintf(genbuf, "home/%c/%s", mytoupper(lookupuser.userid[0]),
		lookupuser.userid);
	deltree(genbuf);
	lookupuser.userlevel = 0;
	strcpy(lookupuser.address, "");
	strcpy(lookupuser.username, "");
	strcpy(lookupuser.realname, "");
	strcpy(lookupuser.ip, "");
	strcpy(lookupuser.realmail, "");
	lookupuser.userid[0] = '\0';
	substitute_record(PASSFILE, &lookupuser, sizeof (lookupuser), id);
	setuserid(id, lookupuser.userid);
}
Exemplo n.º 10
0
static void chc_init(int s, board_t board) {
    userinfo_t *my = currutmp;

    setutmpmode(CHC);
    clear();
    chc_warnmsg[0] = 0;
    chc_my = my->turn;
    chc_mateid = my->mateid;
    chc_firststep = 1;
    chc_init_board(board);
    chc_redraw(board);
    chc_cursor.r = 9, chc_cursor.c = 0;
    add_io(s, 0);
    
    if(my->turn) chc_recvmove(s);
    passwd_query(usernum, &xuser);
    cuser.chc_win = xuser.chc_win;
    cuser.chc_lose = xuser.chc_lose + 1;
    cuser.chc_tie = xuser.chc_tie;
    cuser.money   = xuser.money;
    passwd_update(usernum, &cuser);
    
    getuser(chc_mateid);
    chc_hiswin = xuser.chc_win;
    chc_hislose = xuser.chc_lose;
    chc_histie = xuser.chc_tie;
    
    if(!my->turn) {
	chc_sendmove(s);
	chc_hislose++;
    }
    
    chc_redraw(board);
}
Exemplo n.º 11
0
static int full_user_list(struct user_info *uentp, struct fulluserlistarg* arg,int count)
{
    struct user_info userinfo=*uentp;
    struct userec *lookupuser;
    zval* element;
    if (!userinfo.active || !userinfo.pid) {
        return 0;
    }
    if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && userinfo.invisible && strcmp(userinfo.userid, getCurrentUser()->userid)) {
        /*Haohmaru.99.4.24.让隐身者能看见自己 */
        return 0;
    }
    if (count+1<arg->start)
        return COUNT;
    if (count+1-arg->start>=arg->num)
        return QUIT;
    MAKE_STD_ZVAL ( element );
    array_init ( element );

    add_assoc_bool ( element, "invisible", userinfo.invisible );
    add_assoc_long ( element, "pid", userinfo.pid );
    add_assoc_bool ( element, "isfriend", isfriend(userinfo.userid) );
    add_assoc_string ( element, "userid", userinfo.userid, 1 );
    add_assoc_string ( element, "username", userinfo.username, 1 );
    if( getuser(userinfo.userid, &lookupuser) == 0 ) lookupuser=NULL;
    add_assoc_string ( element, "userfrom", HAS_PERM(getCurrentUser(), PERM_SYSOP)? userinfo.from: SHOW_USERIP(lookupuser, userinfo.from), 1 );
    add_assoc_string ( element, "mode", ModeType(userinfo.mode), 1 );
    add_assoc_long ( element, "idle", (long)(time(0) - userinfo.freshtime)/60 );
    
    zend_hash_index_update(Z_ARRVAL_P(arg->return_value), count+1-arg->start, (void *) &element, sizeof(zval *), NULL);
    return COUNT;
}
Exemplo n.º 12
0
Arquivo: cron.c Projeto: 99years/plan9
void
createuser(void)
{
	Dir d;
	char file[128], *user;
	int fd;

	user = getuser();
	snprint(file, sizeof file, "/cron/%s", user);
	fd = create(file, OREAD, 0755|DMDIR);
	if(fd < 0)
		fatal("couldn't create %s: %r", file);
	nulldir(&d);
	d.gid = user;
	dirfwstat(fd, &d);
	close(fd);
	snprint(file, sizeof file, "/cron/%s/cron", user);
	fd = create(file, OREAD, 0644);
	if(fd < 0)
		fatal("couldn't create %s: %r", file);
	nulldir(&d);
	d.gid = user;
	dirfwstat(fd, &d);
	close(fd);
}
Exemplo n.º 13
0
int
bbspassport_main()
{
	char id[IDLEN + 1], buf[384], site[256];
	struct userec *x;

	html_header(1);
	if (key_fail)
		http_fatal("�ڲ����� ��ϵά��!");
	strsncpy(buf, getparm("pp"), sizeof (buf));
	strsncpy(site, getparm("site"), sizeof (site));
	strsncpy(id, des3_decode(buf, 0), IDLEN + 1);
	if (id[0] && getuser(id, &x) > 0) {
		snprintf(buf, sizeof (buf), "http://%s?q=%s", site,
			 des3_encode(id, 1));
		redirect(buf);
		http_quit();
		return 0;
	}
	printf("<form name=lpassport method=post action=lpassport>\n");
	printf("<table width=100%%>\n");
	printf
	    ("<tr><td align=right>*���������:<td align=left><input name=id size=12 maxlength=%d >\n",
	     IDLEN);
	printf
	    ("<tr><td align=right>*����������:<td align=left><input type=password name=pw size=12 maxlength=%d>\n",
	     PASSLEN - 1);
	printf("<tr><td><td><input type=hidden name=site value=\"%s\">", site);
	printf("<tr><td align=right><input type=submit value=��¼>"
	       " <td align=left><input type=reset value=������д></table>");
	printf("</form>");
	http_quit();
	return 0;
}
Exemplo n.º 14
0
void
extstart(void)
{
	char buf[32];
	int fd;
	static int p[2];
	static void *arg[2];

	if(pipe(p) < 0)
		return;
	sprint(exname, "/srv/sam.%s", getuser());
	fd = create(exname, 1, 0600);
	if(fd < 0){	/* assume existing guy is more important */
    Err:
		close(p[0]);
		close(p[1]);
		return;
	}
	sprint(buf, "%d", p[0]);
	if(write(fd, buf, strlen(buf)) <= 0)
		goto Err;
	close(fd);
	/*
	 * leave p[0] open so if the file is removed the event
	 * library won't get an error
	 */
	plumbc = chancreate(sizeof(int), 0);
	arg[0] = plumbc;
	arg[1] = &p[1];
	proccreate(extproc, arg, 1024);
	atexit(removeextern);
}
Exemplo n.º 15
0
/* 使用者管理 */
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;
}
Exemplo n.º 16
0
void
acmeerrorinit(void)
{
	int pfd[2];

	if(pipe(pfd) < 0)
		error("can't create pipe");
#if 0
	sprint(acmeerrorfile, "/srv/acme.%s.%d", getuser(), mainpid);
	fd = create(acmeerrorfile, OWRITE, 0666);
	if(fd < 0){
		remove(acmeerrorfile);
  		fd = create(acmeerrorfile, OWRITE, 0666);
		if(fd < 0)
			error("can't create acmeerror file");
	}
	sprint(buf, "%d", pfd[0]);
	write(fd, buf, strlen(buf));
	close(fd);
	/* reopen pfd[1] close on exec */
	sprint(buf, "/fd/%d", pfd[1]);
	errorfd = open(buf, OREAD|OCEXEC);
#endif
	fcntl(pfd[0], F_SETFD, FD_CLOEXEC);
	fcntl(pfd[1], F_SETFD, FD_CLOEXEC);
	erroutfd = pfd[0];
	errorfd = pfd[1];
	if(errorfd < 0)
		error("can't re-open acmeerror file");
	proccreate(acmeerrorproc, nil, STACK);
}
Exemplo n.º 17
0
int main(int argc, char **argv)
{
    struct userec *user;
    unsigned char accessed[2];
    char path[PATHLEN];
    int ret;
    if (argc != 5) {
        printf("usage: %s FILENAME USERID TITLE BOARD\n", argv[0]);
        return 0;
    }
    if (!getcwd(path, PATHLEN))
        return -1;
    chdir(BBSHOME);
    resolve_boards();
    resolve_ucache();
    if (!getuser(argv[2], &user)) {
        printf("user %s not found!\n", argv[2]);
        return -2;
    }
    accessed[0] = 0; accessed[1] = 0;
    if (argv[1][0] != '/') {
        strcat(path, "/");
        strcat(path, argv[1]);
    } else {
        memcpy(path, argv[1], PATHLEN);
    }
    if (access(path, R_OK)) {
        printf("file %s not found!\n", argv[1]);
        return -3;
    }
    ret = post_file_alt(path, user, argv[3], argv[4], NULL, 0x04, accessed);
    printf("done, return value = %d\n", ret);
    return 0;
}
Exemplo n.º 18
0
void setuser(const char *user)
{
	uid_t uid;

	if (!strlen(user)) {
		return;
	}

	if (getuid() != 0 && geteuid() != 0) {
		printf("Error: User can only be set as root.\n");
		exit(EXIT_FAILURE);
	}

	if (isnumeric(user) && atoi(user) == 0) {
		return;
	}

	uid = getuser(user);

	if (debug)
		printf("switching to user id %d.\n", uid);

	if (setuid(uid) != 0) {
		perror("Error: setuid");
		exit(EXIT_FAILURE);
	}
}
Exemplo n.º 19
0
int main(int argc, char ** argv)
{
	int all = 0;
	struct boardheader *bp;
	struct userec* sysopuser;

    if (init_all()) {
        printf("init data fail\n");
        return -1;
    }

	getuser("SYSOP", &sysopuser);
	setCurrentUser(sysopuser);
	if (argc == 1)
		all = 1;
	else if (argc > 2)
	{
		printf("Usage: %s [boardid]\n", argv[0]);
		return -1;
	}
	if (all == 1)
	{
		apply_boards(cnv_board_dir,NULL);
	}
	else
	{
		if ((bp = getbcache(argv[1])) != NULL)
			cnv_board_dir(bp,NULL);
	}

	return 0;
}
Exemplo n.º 20
0
Arquivo: tagfs.c Projeto: ericvh/tagfs
void
threadmain(int argc, char* argv[])
{
	char*	mnt;
	char*	srv;
	int	mflag;
	Biobuf*	b;
	char*	user;

	srv = nil;
	mnt = nil;
	mflag = MREPL|MCREATE;
	ARGBEGIN{
	case 'a':
		mflag = MAFTER|MCREATE;
		break;
	case 'b':
		mflag = MBEFORE|MCREATE;
		break;
	case 'c':
		mflag = MREPL|MCREATE;
		break;
	case 's':
		srv = EARGF(usage());
		break;
	case 'm':
		mnt = EARGF(usage());
		break;
	case 'D':
		debug = 1;
		chatty9p++;
		break;
	default:
		usage();
	}ARGEND;
	if(argc != 1)
		usage();

	tfname = argv[0];
	ttfname = smprint("%s.new", tfname);
	b = Bopen(tfname, OREAD);
	if(b == nil)
		sysfatal("%s: %r", tfname);
	trie = rdtrie(b);
	Bterm(b);
	if(trie == nil)
		sysfatal("%s: %r", tfname);

	if(srv == nil && mnt == nil){
		mnt = "/mnt/tags";
		srv = srvname(tfname);
	}
	if(!chatty9p)
		rfork(RFNOTEG);
	sfs.tree =  alloctree(nil, nil, DMDIR|0777, nil);
	user = getuser();
	ctlf = createfile(sfs.tree->root, "ctl", user, 0666, nil);
	threadpostmountsrv(&sfs, srv, mnt, mflag);
	threadexits(nil);
}
Exemplo n.º 21
0
int
show_onlinestate(char *userid)
{
	int uid, i, uent, num = 0;
	struct user_info *uentp;
	uid = getuser(userid, NULL);
	if (uid <= 0 || uid > MAXUSERS)
		return 0;
	for (i = 0; i < 6; i++) {
		uent = uindexshm->user[uid - 1][i];
		if (uent <= 0 || uent > MAXACTIVE)
			continue;
		uentp = &(shm_utmp->uinfo[uent - 1]);
		if (!uentp->active || !uentp->pid || uentp->uid != uid)
			continue;
		if (uentp->invisible && !USERPERM(currentuser, PERM_SEECLOAK))
			continue;
		num++;
		if (num == 1)
			printf("目前在站上, 状态如下:\n");
		if (uentp->invisible)
			printf("<font color=olive>C</font>");
		printf("<font color=%s>%s</font> ",
		       uentp->pid == 1 ? "magenta" : "blue",
		       ModeType(uentp->mode));
		if (num % 5 == 0)
			printf("<br>");
	}
	return num;
}
Exemplo n.º 22
0
int get_process_info_sysdep(ProcInfo_T p) {
    
  int nproc;
  int i,rv;
  struct userinfo user;
  
  memset(&user,0,sizeof(struct userinfo));
  nproc=getproc(procs,NPROCS,sizeof(struct procinfo));
  for(i=0;i<nproc;i++) {
    
    if(p->pid==procs[i].pi_pid) {
      
      if(procs[i].pi_stat==SZOMB) {

empty:

	p->cputime_prev= p->cputime = 0;
	p->mem_kbyte= 0;
	p->mem_percent= 0.0;
	p->status_flag |= PROCESS_ZOMBIE;
 
     } else {

       rv=getuser(&(procs[i]),sizeof(struct procinfo),
		  &user,sizeof(struct userinfo));
      
       if(rv== -1) {

	 goto empty;

       }

       p->mem_percent = user.ui_prm*10;
       p->mem_kbyte = (user.ui_drss+user.ui_trss)*4;
       
       p->cputime_prev= p->cputime;
       p->cputime= ( timestruc_to_tseconds(user.ui_ru.ru_utime) +
		     timestruc_to_tseconds(user.ui_ru.ru_stime));
       
       if( include_children ) {
	 p->cputime+= ( 
		       timestruc_to_tseconds(user.ui_cru.ru_utime)+
		       timestruc_to_tseconds(user.ui_cru.ru_stime));
       }
       /* first run ? */
       if ( p->time_prev == 0.0 ) {
	
	 p->cputime_prev= p->cputime;

       }       
     }    
      
      return TRUE; 

    }
  }

  return FALSE;
    
}
Exemplo n.º 23
0
Arquivo: xyz.c Projeto: fbbs/fbbs
//      pager与msg设定
//
int x_userdefine() {
	int id;
	unsigned int newlevel;
	set_user_status(ST_USERDEF);
	if (!(id = getuser(currentuser.userid))) {
		screen_move_clear(3);
		screen_printf("错误的使用者 ID...");
		pressreturn();
		screen_clear();
		return 0;
	}
	screen_move(1, 0);
	screen_clrtobot();
	screen_move(2, 0);
	use_define = 1;
	newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES,
			showperminfo);
	screen_move(2, 0);
	if (newlevel == lookupuser.userdefine)
		screen_printf("参数没有修改...\n");
	else {
		lookupuser.userdefine = newlevel;
		currentuser.userdefine = newlevel;
		substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id);
		screen_printf("新的参数设定完成...\n\n");
	}
	pressreturn();
	screen_clear();
	use_define = 0;
	return 0;
}
Exemplo n.º 24
0
//      pager与msg设定
//
int x_userdefine() {
    int id;
    unsigned int newlevel;
    set_user_status(ST_USERDEF);
    if (!(id = getuser(currentuser.userid))) {
        screen_move_clear(3);
        //% prints("错误的使用者 ID...");
        prints("\xb4\xed\xce\xf3\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf ID...");
        pressreturn();
        screen_clear();
        return 0;
    }
    screen_move(1, 0);
    screen_clrtobot();
    screen_move(2, 0);
    use_define = 1;
    //% newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES,
    newlevel = setperms(lookupuser.userdefine, "\xb2\xce\xca\xfd", NUMDEFINES,
                        showperminfo);
    screen_move(2, 0);
    if (newlevel == lookupuser.userdefine)
        //% prints("参数没有修改...\n");
        prints("\xb2\xce\xca\xfd\xc3\xbb\xd3\xd0\xd0\xde\xb8\xc4...\n");
    else {
        lookupuser.userdefine = newlevel;
        currentuser.userdefine = newlevel;
        substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id);
        //% prints("新的参数设定完成...\n\n");
        prints("\xd0\xc2\xb5\xc4\xb2\xce\xca\xfd\xc9\xe8\xb6\xa8\xcd\xea\xb3\xc9...\n\n");
    }
    pressreturn();
    screen_clear();
    use_define = 0;
    return 0;
}
Exemplo n.º 25
0
Arquivo: auth.c Projeto: bhanug/harvey
int
vncsrvauth(Vnc *v)
{
	Chalstate *c;
	AuthInfo *ai;

	if((c = auth_challenge("proto=vnc role=server user=%q", getuser()))==nil)
		sysfatal("vncchal: %r");
	if(c->nchal != VncChalLen)
		sysfatal("vncchal got %d bytes wanted %d", c->nchal, VncChalLen);
	vncwrlong(v, AVncAuth);
	vncwrbytes(v, c->chal, VncChalLen);
	vncflush(v);

	vncrdbytes(v, c->chal, VncChalLen);
	c->resp = c->chal;
	c->nresp = VncChalLen;
	ai = auth_response(c);
	auth_freechal(c);
	if(ai == nil){
		fprint(2, "vnc auth failed: server factotum: %r\n");
		vncwrlong(v, VncAuthFailed);
		vncflush(v);
		return -1;
	}
	auth_freeAI(ai);
	vncwrlong(v, VncAuthOK);
	vncflush(v);

	return 0;
}
Exemplo n.º 26
0
void
logout(void)
{
struct user *tmpuser;
char   *uname;
struct btmp btmp;

  uname = get_name("Name of user to log out? ", 2);
 
  if (*uname)
  {
    if (!(tmpuser = getuser(uname)))
      printf("There is no user %s on this BBS.\n", uname);
    else
    {
      if (tmpuser->f_prog && !ouruser->f_prog)
        printf("Can't do that!\n");
      else if (!is_online(&btmp, tmpuser, NULL))
        printf("%s is not online.\n", uname);
      else
	logout_user(tmpuser, NULL, 0);
      freeuser(tmpuser);
    }
  }
}
Exemplo n.º 27
0
Arquivo: cpu-bl.c Projeto: npe9/harvey
/*
 *  prompt user for a key.  don't care about memory leaks, runs standalone
 */
static Attr*
promptforkey(char *params)
{
	char *v;
	int fd;
	Attr *a, *attr;
	char *def;

	fd = open("/dev/cons", ORDWR);
	if(fd < 0)
		sysfatal("opening /dev/cons: %r");

	attr = _parseattr(params);
	fprint(fd, "\n!Adding key:");
	for(a=attr; a; a=a->next)
		if(a->type != AttrQuery && a->name[0] != '!')
			fprint(fd, " %q=%q", a->name, a->val);
	fprint(fd, "\n");

	for(a=attr; a; a=a->next){
		v = a->name;
		if(a->type != AttrQuery || v[0]=='!')
			continue;
		def = nil;
		if(strcmp(v, "user") == 0)
			def = getuser();
		a->val = readcons(v, def, 0);
		if(a->val == nil)
			sysfatal("user terminated key input");
		a->type = AttrNameval;
	}
	for(a=attr; a; a=a->next){
		v = a->name;
		if(a->type != AttrQuery || v[0]!='!')
			continue;
		def = nil;
		if(strcmp(v+1, "user") == 0)
			def = getuser();
		a->val = readcons(v+1, def, 1);
		if(a->val == nil)
			sysfatal("user terminated key input");
		a->type = AttrNameval;
	}
	fprint(fd, "!\n");
	close(fd);
	return attr;
}
Exemplo n.º 28
0
Arquivo: cpu.c Projeto: 99years/plan9
static int
srvnoauth(int fd, char *user)
{
	strecpy(user, user+MaxStr, getuser());
	ealgs = nil;
	newns(user, nil);
	return fd;
}
Exemplo n.º 29
0
Arquivo: unix.c Projeto: floren/sam
void
extstart(void)
{
#ifndef	NOFIFO
	char	*disp;
	char	*user;
	int	fd;
	int	flags;

	user = getuser();
	disp = getenv("DISPLAY");

	if (disp) {
		exname = (char *)alloc(4 + 6 + strlen(user) + 1 + strlen(disp) + 1);
		sprint(exname, "/tmp/.sam.%s.%s", user, disp);
	} else { 
		exname = (char *)alloc(4 + 6 + strlen(user) + 1);
		sprint(exname, "/tmp/.sam.%s", user);
	}

	/* Make the named pipe.  Multiple sams with the same user/display share the same pipe */
	if (mkfifo(exname, 0600) == -1) {
		struct stat	statb;
		extern int	errno;

		if (errno != EEXIST || stat(exname, &statb) == -1)
			return;

		if (!S_ISFIFO(statb.st_mode)) {
			removeextern();
			if (mkfifo(exname, 0600) == -1)
				return;
		}
	}

	fd = open(exname, O_RDONLY | O_NONBLOCK);
	if (fd == -1) {
		removeextern();
		return;
	}

	/*
	 * Turn off no-delay and provide ourselves as a lingering
	 * writer so as not to get end of file on read.
         */ 
	flags = fcntl(fd, F_GETFL, 0);
	if (flags == -1 || fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == -1
			|| open(exname, O_WRONLY) == -1) {
		(void)close(fd);
		removeextern();
		return;
	}

	estart(Eextern, fd, 8192);
	atexit(removeextern);
#endif
}
Exemplo n.º 30
0
Arquivo: unix.c Projeto: 8l/sam
void
samerr(char *buf)
{
	int j;

	j = getpid();
	do sprint(buf, "%s/sam%05d%.6s", TMPDIR, j++, getuser());
	while (access(buf, 0) == 0);
}