|
|
|
@ -339,6 +339,66 @@ int find_user(char *name, char *tty, char *disp) {
|
|
|
|
|
|
|
|
|
|
#else /*not PROC_FIND_USER*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UTMPX_H
|
|
|
|
|
|
|
|
|
|
int find_user(char *name, char *tty, char *disp) {
|
|
|
|
|
|
|
|
|
|
struct utmpx *ubuf;
|
|
|
|
|
int status;
|
|
|
|
|
struct stat statb;
|
|
|
|
|
char ftty[20 + sizeof ubuf->ut_line];
|
|
|
|
|
char ttyFound[sizeof ubuf->ut_line] = "";
|
|
|
|
|
char dispFound[sizeof ubuf->ut_line + 1] = "";
|
|
|
|
|
|
|
|
|
|
setutxent();
|
|
|
|
|
#define SCMPN(a, b) strncmp(a, b, sizeof (a))
|
|
|
|
|
status = NOT_HERE;
|
|
|
|
|
(void) strcpy(ftty, _PATH_DEV);
|
|
|
|
|
while ((ubuf = getutxent())) {
|
|
|
|
|
if ((ubuf->ut_type == USER_PROCESS) &&
|
|
|
|
|
(!SCMPN(ubuf->ut_user, name))) {
|
|
|
|
|
if (*tty == '\0') {
|
|
|
|
|
/* no particular tty was requested */
|
|
|
|
|
(void) strcpy(ftty+5, ubuf->ut_line);
|
|
|
|
|
if (stat(ftty,&statb) == 0) {
|
|
|
|
|
if (!(statb.st_mode & 020)) /* ?character device? */
|
|
|
|
|
continue;
|
|
|
|
|
(void) strcpy(ttyFound, ubuf->ut_line);
|
|
|
|
|
#ifdef USE_UT_HOST
|
|
|
|
|
(void) strcpy(dispFound, ubuf->ut_host);
|
|
|
|
|
strcat(dispFound, " ");
|
|
|
|
|
#endif
|
|
|
|
|
status = SUCCESS;
|
|
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "%s", ttyFound);
|
|
|
|
|
if ((int) ttyFound[3] > (int) 'f') {
|
|
|
|
|
#ifdef USE_UT_HOST
|
|
|
|
|
if (Options.debug_mode) {
|
|
|
|
|
syslog(LOG_DEBUG, "I wanna this:%s", ttyFound);
|
|
|
|
|
syslog(LOG_DEBUG, "ut_host=%s", ubuf.ut_host);
|
|
|
|
|
syslog(LOG_DEBUG, "%s", ubuf.ut_line);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp(ubuf->ut_line, tty)) {
|
|
|
|
|
status = SUCCESS;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
endutxent();
|
|
|
|
|
if (status == SUCCESS) {
|
|
|
|
|
(void) strcpy(tty, ttyFound);
|
|
|
|
|
(void) strcpy(disp, dispFound);
|
|
|
|
|
}
|
|
|
|
|
return (status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else /* HAVE_UTMPX_H */
|
|
|
|
|
|
|
|
|
|
int find_user(char *name, char *tty, char *disp) {
|
|
|
|
|
|
|
|
|
|
struct utmp ubuf;
|
|
|
|
@ -397,4 +457,7 @@ int find_user(char *name, char *tty, char *disp) {
|
|
|
|
|
}
|
|
|
|
|
return (status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* HAVE_UTMPX_H */
|
|
|
|
|
|
|
|
|
|
#endif /*PROC_FIND_USER*/
|
|
|
|
|