亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? utmp.c

?? 一個使用des加密傳輸的unix下的login程序的服務器端和客戶端
?? C
字號:
/* * @(#) utmp.c  RCS: $Revision: 1.8 $ $Date: 95/03/08 01:13:19 $ * * This file contains machine specific code for making sure getlogin() works. * See the function setlogin below. * * Make sure login database is updated getut(3c), but this is not  * available in POSIX, or SYSV XPG3; it's only a SYSV XPG2 feature.    * There thus is no machine independent way to make getlogin work. * * There are two distinct flavors of utmp.h files: * * System V style:  SGI's IRIX, Solaris, OSF1, HP-UX, UNICOS #    #define ut_name	ut_user *    struct utmp {  *	 char[] ut_user, ut_id, ut_line; *	 short ut_pid, ut_type; *	 struct { short e_termination; short e_exit } ut_exit;	except linux *	 time_t ut_time; *       char ut_host[]; // HP-UX, OSF1, UNICOS linux only !Solaris <utmp.h> *    } * * UTMPX style: Solaris	<utmpx.h> (*almost* the same as system V style!) *     struct utmpx {			<- different name *        char[] ut_user, ut_id, ut_line; *        pid_t ut_pid; *        short ut_type; *        struct exit_status ut_exit;	<- same *        struct timeval ut_tv;		<- different! (BSD style timeofday) *        long  ut_session; *        short ut_syslen; *        char ut_host[]; *     } * *  BSD style:	Ultrix, SunOS4.2, UNICOS *     struct utmp { *	   char ut_line[8], ut_name[8], ut_host[16]; *	   long ut_time; *     } *  * The least-common denominator of utmp entries: *     char ut_line[] 	  device name without path component (e.g. "ttyp4") *     			  8 chars on BSD, 12 on hp-ux, longer on osf1 *     time_t ut_time	  time entry was made (long on BSD) *     char   ut_name[8]  login name of the user * * The following field is not present on SGI's IRIX and Solaris. *     char   ut_host[16] host name if remote * * Unfortunately, BSD and System V use different names for the field containing * the user login name (ut_name, ut_user respectively).  Fortunately, all * SYSV machines I can find have a #define for ut_name. * * For BSD, empty slots are indicated by ut_name is a null string. * Remote users are indicated by a non-null ut_host field. * * For System V, empty slots are indicated by ut_type field as  * DEAD_PROCESS. All other fields must be valid as usual. * * Solaris has two utmp files with different struct formats: *    /var/adm/utmp  based on <utmp.h>  using struct utmp.	UTMP_FILE *    /var/adm/utmpx based on <utmpx.h> using struct utmpx.	UTMPX_FILE * *    Changes UTMPX_FILE will not be noticed by the "last" and "who" commands  *    unless UTMP_FILE is also updated.  UTMPX_FILE has an rhost field. */#define _POSIX_SOURCE	/* this isn't quite posix source *//* * This is a mess.  HP-UX ANSI C won't define pid_t in <sys/types.h> unless * _POSIX_SOURCE is defined.  Other machines may refuse to define it.  Pick * what's appropriate.  <utmp.h> uses pid_t. */#if defined(__SOLARIS__) /* { */#undef _POSIX_SOURCE	/* allows struct timeval to be defined */#undef _POSIX_C_SOURCE#include <sys/types.h>	/* uid_t size_t */#include <time.h>	/* time (also needed for "utmp.h") */#define _POSIX_SOURCE#define _POSIX_C_SOURCE#else  /* } { */#include <sys/types.h>	/* uid_t size_t */#include <time.h>	/* time (also needed for "utmp.h") */#endif /* } */#include <unistd.h>	/* open read write lseek getuid */#include <stdio.h>#include <fcntl.h>	/* O_RDWR */#include <string.h>	/* strchr memset */#include <pwd.h>	/* struct passwd, getpwuid */#define OFFSET(s, m)	((unsigned) &(((s *)0)->m))#include "utmp.h"	/* UTMP_FILE WTMP_FILE <utmp.h> or <utmpx.h> */#include "log.h"#include "deslogin.h"	/* progName ERRMSG *//* * Update the system's "currently logged in users" file (used by "who") * * Input: *    utmp_file 	- the name of the file to update *    ut		- address of the record insert into file *    utbuf		- storage for a temporary buffer *    utsz		- the size of the ut and utbuf record's storage *    lineoff		- the offset into the record for the ut_line field *    linesz		- the size of the ut_line field * * Must minimize the time the file is open to prevent write conflict with * other processes trying to update utmp.   */int update_utmp(utmp_file, ut, utbuf, utsz, lineoff, linesz)   char *utmp_file;   void *ut, *utbuf;   unsigned utsz, lineoff, linesz;{   int fd, count, res = -1;   long offset = 0, lres;   fd = open(utmp_file, O_RDWR);   if (fd < 0) {      log("%s: (update_utmp) open(\"%s\", O_RDWR) failed -- %s\n", 	 progName, utmp_file, ERRMSG);      return -1;   }   /*     * Find offset of entry with the same line value if present    */   while ((count = read(fd, utbuf, utsz)) == utsz) {      if (strncmp((char *)ut+lineoff, (char *)utbuf+lineoff, linesz) == 0) {	 break;      }      offset += count;   }   if (count < 0) {      log("%s: (update_utmp) read failed from \"%s\" -- %s\n", 	 progName, utmp_file, ERRMSG);      goto utmp_failed;   }   lres = lseek(fd, (off_t) offset, SEEK_SET);   if (lres < 0) {      log("%s: (update_utmp) lseek to offset %ld failed in \"%s\" -- %s\n", 	 progName, offset, utmp_file, ERRMSG);      goto utmp_failed;   }   count = write(fd, (char *) ut, utsz);   if (count < 0) {      log("%s: (update_utmp) write failed to \"%s\" -- %s\n", 	 progName, utmp_file, ERRMSG);      goto utmp_failed;   }   if (count != utsz) {      log("%s: (update_utmp) short write to \"%s\"\n", progName, utmp_file);      goto utmp_failed;   }   res = 0;	/* success */utmp_failed:   close(fd);   return res;}/* * Update the system login history file (used by "last" and "lastb") * * Must minimize the time the file is open to prevent write conflict with * other processes trying to update utmp.   */int update_wtmp(wtmp_file, ut, utsz)   char *wtmp_file;   void *ut;   unsigned utsz;{   int fd, count, res = -1;   fd = open(wtmp_file, O_WRONLY | O_APPEND);   if (fd < 0) {      log("%s: (update_wtmp) open(\"%s\", O_WRONLY|O_APPEND) failed -- %s\n", 	 progName, wtmp_file, ERRMSG);      return -1;   }   count  = write(fd, ut, utsz);   if (count < 0) {      log("%s: (update_wtmp) write failed to \"%s\" -- %s\n", 	 progName, wtmp_file, ERRMSG);      goto wtmp_failed;   }   if (count != utsz) {      log("%s: (update_wtmp) short write to \"%s\"\n", progName, wtmp_file);      goto wtmp_failed;   }   res = 0;	/* success */wtmp_failed:   close(fd);   return res;}/* * The inverse of the POSIX getlogin call.  Setup the login for the given * user name. * * Input: *    tty   = the device file assigned as the controlling terminal *    name  = the login name (only first 8 characters signifacant) *    rhost = the hostname of the remote host (only 1st 16 chars used) *    statloc = the address of the process exit status *              (if zero, then this is a new process stating up) * * The calling process should ensure that it owns the tty before it calls * this routine, or it could overwrite a legitimate processes tty. * * Returns: 0 success, -1 failure. */int setlogin(tty, username, rhost, statloc)   char *tty, *username, *rhost;   int *statloc;{   char         *line, *id;   long         offset;   int          res;   struct utmp  ut, utbuf;#if defined(UTMPX_FILE) 	/* { */   struct utmpx utx, utxbuf;#endif /* } */   if ((tty == 0) || (username == 0) || (rhost == 0)) return -1;   /*    * There are two possibly conflicting ways to get the line:    *   1) take the last component of the path (SYSV) (e.g. fails for /dev/pts/6)    *   2) Strip of the first component of the path. (irix) (/dev/pts/6 = pts/6)    *   3) Don't strip any components at all (Solaris)    *    * Which one is the most "popular"?  Probably should be a compile-time test.    * I'm using the last component of the path.    */   line = strchr(tty, '/');   if (line == tty) {      line = strchr(tty + 1, '/');      if (line == (char *) 0) line = tty;   }   if (line == (char *) 0) line = tty; else line++;   /*    * The id field (for init) is the last two characters of the line on SYSV    * For SOLARIS, id is prefixed by two character service abbreviation.    *    (e.g. Telnet is 'tn', rlogin is 'rl')    * I'm using the last two characters of the line.    */   offset = strlen(line) - 2;   if (offset < 0) offset = 0;   id = line + offset;#if defined(UTMPX_FILE) 	/* { */   memset(&utx, '\0', sizeof utx);#endif /* } */   memset(&ut, '\0', sizeof ut);   time((time_t *) &ut.ut_time);   strncpy(ut.ut_line, line,     sizeof ut.ut_line);   strncpy(ut.ut_name, username, sizeof ut.ut_name); #if defined(USER_PROCESS)		/* { SYSV */   strncpy(ut.ut_id,    id,      sizeof ut.ut_id);   ut.ut_pid  = getpid();   ut.ut_type = USER_PROCESS;		/* assume login until proven othewise */   if (statloc != 0) {		/* process exit */      ut.ut_type = DEAD_PROCESS;#if !defined(_LINUX_SOURCE) /* { */      ut.ut_exit.e_termination = *statloc & 0xff;      ut.ut_exit.e_exit        = (*statloc >> 8) & 0xff;#endif /* } */   }#else 	/* } { BSD */   if (statloc != 0) {      ut.ut_name[0] = '\0';   }#endif	/* } BSD */#if !defined(__sgi) && !defined(__DYNIX__) && !defined(__SOLARIS__) /* { */   strncpy(ut.ut_host, rhost, sizeof ut.ut_host);#endif /* } */   /*    * This used to be broken for __DYNIX__ and __SOLARIS__.    * Version 1.3 fixed this.  If not, mail barrett@asgard.cs.colorado.edu    */   res = update_utmp(UTMP_FILE, &ut, &utbuf, sizeof ut,                      OFFSET(struct utmp, ut_line), sizeof ut.ut_line);   if (res >= 0) {      res = update_wtmp(WTMP_FILE, &ut, sizeof ut);    }#if defined(UTMPX_FILE) /* { __SOLARIS__ <utmpx.h> */   getutmpx(&ut, &utx);		/* no return result */   gettimeofday(&utx.ut_tv);	/* shouldn't be necessary; do it anyway */   strncpy(utx.ut_host, rhost, sizeof utx.ut_host);   if (res >= 0) {      res = update_utmp(UTMPX_FILE, &utx, &utxbuf, sizeof utx, 	                OFFSET(struct utmpx, ut_line), sizeof utx.ut_line);   }   if (res >= 0) {      res = update_wtmp(WTMPX_FILE, &utx, sizeof utx);    }#endif /* } */   return res;}/* * Because of severe braindamage, the POSIX getlogin() call has a  * high-probability of failing to work on many machines.  The things to * consider are: * * This process must have a controlling terminal to determine the tty line * to lookup in utmp. * * There must be a (unique) entry for that line in utmp. *  * There is no guarantee that the contents of utmp is correct. (It's world * writable on most SUN BSD machines for example!  Thus, the login name  * returned there may not be correct at all. * * cuserid() is obsolete.  The problem is that it could return the login * name corresponding to the effective user id instead of the real user id. * * There may be multiple user names corresponding to each user id.   * * The bottom line is that there is *no way* to accurately determine which * of the (possibly many) login names were used to get this particular real * user id. * * I've decided not to trust utmp at all, and just to get the first valid * user id using the POSIX.1 conformant calls to <pwd.h>, getpwuid. * * Note that the only "portable" fields of a struct passwd are: * *    char *pw_name *    char *pw_passwd *    uid_t pw_uid *    gid_t pw_gid * * The only way this routine should fail (returning (char *) 0) is if  * /etc/passwd is not readable.  Note that yellow-pages lookups could occur * as a result of using this function. * * AnnexB.4.2.4:2682-2694 * The getlogin() function returns a pointer to the user's login name.  The * same user ID may be shared by several login names.  If it is desired to get * the user database entry that is used during login, the result of getlogin() * should be used to provide the argument to the getpwnam() function.  (This * might be  used to determine the user's login shell, particularly where a * single user has multiple login shells with distinct login names, but the * same user ID.) *    The information provided by the cuserid() function, which was originally * defined in IEEE Std 1003.1-1990 and subsequently removed, can be obtained * by the following:  getpwuid(geteuid()), while the information provided by * historical implementations of cuserid() can be obtained by: * getpwuid(getuid()). */char *getLoginName() {   register uid_t uid = getuid();   register struct passwd *pwent;      pwent = getpwuid(uid);   if (pwent == (struct passwd *) 0) {      return (char *) 0;   } else {      return pwent->pw_name;   }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频一区二区在线观看| 久久精品国产一区二区| 成人手机在线视频| 国产欧美一区二区精品秋霞影院| 国产高清在线精品| 国产精品美女久久久久久久 | 亚洲成人你懂的| 欧美精品乱码久久久久久按摩| 婷婷开心久久网| 精品剧情在线观看| 成人国产精品免费观看| 亚洲伦在线观看| 欧美日韩亚洲综合在线| 久久99这里只有精品| 中文字幕av免费专区久久| 在线欧美一区二区| 丝袜亚洲另类欧美| 国产日韩欧美综合在线| 色妹子一区二区| 美女www一区二区| 国产精品美女一区二区在线观看| 欧美亚洲高清一区| 激情久久五月天| 亚洲色图.com| 日韩精品一区国产麻豆| 99久久免费国产| 麻豆成人久久精品二区三区红 | 综合色天天鬼久久鬼色| 欧美日韩日日摸| 国产成人免费视频网站| 婷婷丁香激情综合| 国产精品美女www爽爽爽| 欧美另类videos死尸| 成人激情综合网站| 日本不卡视频一二三区| 国产精品短视频| 日韩欧美国产一区在线观看| 成人免费视频视频| 久久av中文字幕片| 亚洲一区二区三区在线| 中文欧美字幕免费| 日韩一二三区视频| 色素色在线综合| 国产乱国产乱300精品| 午夜欧美电影在线观看| 国产精品嫩草影院av蜜臀| 91精品国产高清一区二区三区蜜臀 | 欧美日韩国产综合久久| 成人av午夜影院| 国产在线不卡一卡二卡三卡四卡| 亚洲一区在线视频| 国产精品国产三级国产aⅴ无密码| 日韩一区二区影院| 欧美日韩在线播放三区四区| 成人午夜视频福利| 国产成人免费在线视频| 全国精品久久少妇| 婷婷综合久久一区二区三区| 亚洲欧美日韩精品久久久久| 欧美激情一区二区在线| 精品欧美一区二区三区精品久久| 在线观看成人免费视频| 99久久久国产精品免费蜜臀| 成人视屏免费看| 国产河南妇女毛片精品久久久| 精品一区二区三区蜜桃| 老司机精品视频导航| 日本欧美在线观看| 午夜成人免费视频| 五月婷婷激情综合网| 亚洲成av人片观看| 午夜久久电影网| 三级成人在线视频| 五月天欧美精品| 日韩成人精品视频| 青娱乐精品视频| 日韩精品国产欧美| 青青青伊人色综合久久| 免费成人在线视频观看| 久久99精品一区二区三区三区| 麻豆精品在线观看| 极品瑜伽女神91| 国产精品123区| 成人av动漫网站| 色偷偷成人一区二区三区91| 在线看日韩精品电影| 欧美日韩免费观看一区三区| 欧美日韩成人综合| 精品少妇一区二区三区在线播放| 亚洲精品一区二区三区在线观看| 26uuuu精品一区二区| 久久精品日产第一区二区三区高清版| 中文字幕精品一区| 欧美丰满一区二区免费视频| 精品国产一区二区三区av性色| 成人精品一区二区三区四区| 国产麻豆视频一区二区| 亚洲一二三专区| 天堂成人国产精品一区| 激情综合色丁香一区二区| 国产成人8x视频一区二区| 91在线国产福利| 欧美精品丝袜中出| 精品动漫一区二区三区在线观看| 日本一区二区三区四区| 亚洲三级在线观看| 日韩va欧美va亚洲va久久| 国产综合久久久久久鬼色| 91丨porny丨国产| 91精品国产综合久久久蜜臀图片| 久久综合狠狠综合久久综合88| 中文字幕一区二区三区在线播放| 亚洲免费在线看| 久久国产尿小便嘘嘘尿| 91一区二区在线观看| 日韩亚洲欧美在线观看| 国产精品视频观看| 午夜电影一区二区三区| 成人激情视频网站| 日本一区二区在线不卡| 欧美一区二区日韩一区二区| 欧美午夜精品一区二区蜜桃| 欧美大片顶级少妇| 一区二区在线电影| 激情综合色播五月| 在线观看一区二区精品视频| 精品99一区二区三区| 亚洲国产综合色| 成人一区在线看| 日韩欧美一级特黄在线播放| 中文字幕亚洲在| 国产精品影音先锋| 欧美一区二区三区在线| 亚洲老妇xxxxxx| 成人免费视频播放| 久久综合国产精品| 天堂蜜桃91精品| 色婷婷久久久亚洲一区二区三区| 精品免费视频.| 午夜精品一区在线观看| 在线观看日韩电影| 国产亚洲视频系列| 看片的网站亚洲| 欧美日韩精品专区| 亚洲另类春色校园小说| 成人福利视频在线| 国产视频在线观看一区二区三区| 亚洲123区在线观看| 在线视频国内自拍亚洲视频| 国产精品久久久久婷婷二区次| 九九国产精品视频| 日韩一卡二卡三卡国产欧美| 亚洲国产日韩一级| 色8久久人人97超碰香蕉987| 国产精品毛片大码女人| 国产成人啪午夜精品网站男同| 精品国产乱码久久| 精品系列免费在线观看| 在线综合视频播放| 日韩av一级电影| 欧美一区二区三区四区五区| 亚洲第一会所有码转帖| 欧美性大战久久| 亚洲大型综合色站| 欧美色倩网站大全免费| 亚洲一区二区在线观看视频| 欧美午夜视频网站| 午夜欧美大尺度福利影院在线看| 欧美三级三级三级| 视频一区视频二区中文| 欧美一区在线视频| 久久精品国产亚洲一区二区三区| 欧美xxxxxxxx| 国产一区二区三区久久久| 久久久国产精华| 不卡电影免费在线播放一区| 国产精品色婷婷久久58| 91论坛在线播放| 亚洲国产精品一区二区www在线 | 美腿丝袜亚洲一区| 精品伦理精品一区| 国产福利一区在线观看| 国产精品嫩草影院av蜜臀| 色噜噜夜夜夜综合网| 亚洲尤物视频在线| 欧美一区二区三区免费| 国产一区二区在线免费观看| 国产精品久久久久婷婷| 在线观看av一区| 蜜桃视频在线一区| 久久久精品黄色| 91香蕉视频污| 视频一区欧美日韩| 欧美精品一区二区三区蜜臀| 国产91精品免费| 一级日本不卡的影视| 日韩视频一区二区| 成人免费看片app下载| 一区二区三区欧美日韩| 欧美一级在线视频|