-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdo_utmp.c
98 lines (85 loc) · 2.11 KB
/
do_utmp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <string.h>
#include <utmp.h>
#include "utmp.h"
static char *find_id(char *lite);
static char id[4];
void
add_utmp(char *tty,char *x25addr) {
//Printf(0,"tty %s\n",tty);
// strncpy(id,find_id(tty),4);
//Printf(0,"Utmp id %s\n",id);
// struct utmp uline, *retu;
// if (utmpname(_PATH_UTMP)) {
// Printf(0,"Cant open utmp(%s) database\n",_PATH_UTMP);
// Exit(1);
// }
//
// setutent();
// uline.ut_type = LOGIN_PROCESS;
// // uline.ut_pid = pid;
// strncpy(uline.ut_id,id,4);
// strncpy(uline.ut_line,tty,UT_LINESIZE);
// strncpy(uline.ut_host,x25addr,UT_HOSTSIZE);
//
// pututline(&uline);
//
// endutent();
}
void
clean_utmp () {
//Printf(0,"Clean utmp id %s\n",id);
// struct utmp uline, *retu;
// if (utmpname(_PATH_UTMP)) {
// Printf(0,"Cant open utmp(%s) database\n",_PATH_UTMP);
// Exit(1);
// }
//
// setutent();
// uline.ut_type = USER_PROCESS;
// strcpy(uline.ut_id,id);
//
// while ((retu = getutid(&uline)) != NULL) {
//
// Printf(1,"Clean in utmp pid %i\n",retu->ut_pid);
// retu->ut_type = DEAD_PROCESS;
// memset(retu->ut_user,0,UT_NAMESIZE);
// memset(retu->ut_host,0,UT_HOSTSIZE);
// retu->ut_tv.tv_sec = 0;
// retu->ut_tv.tv_usec = 0;
//
// retu->ut_time = 0;
//
// retu = pututline(retu);
// if (retu == NULL) {
// printf(0,"pututline error\n");
// }
//
// }
// // else {
// // Printf(0,"utmp line not found\n");
// // }
//
// endutent();
}
static char *
find_id(char *lite) {
while (isdigit(*lite) == 0) {
lite++;
}
return(lite);
}