id.c (32663) | id.c (33603) |
---|---|
1/*- 2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: id.c,v 1.5 1997/12/27 19:23:12 brian Exp $ | 26 * $Id: id.c,v 1.6 1998/01/21 02:15:16 brian Exp $ |
27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31 32#include <sys/ioctl.h> 33#include <fcntl.h> 34#include <stdio.h> | 27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31 32#include <sys/ioctl.h> 33#include <fcntl.h> 34#include <stdio.h> |
35#include <string.h> |
|
35#include <sysexits.h> 36#include <unistd.h> | 36#include <sysexits.h> 37#include <unistd.h> |
37 38#include "command.h" 39#include "mbuf.h" 40#include "log.h" 41#include "main.h" | |
42#ifdef __OpenBSD__ 43#include <util.h> 44#else 45#include <libutil.h> 46#endif | 38#ifdef __OpenBSD__ 39#include <util.h> 40#else 41#include <libutil.h> 42#endif |
43#include <utmp.h> 44 45#include "command.h" 46#include "mbuf.h" 47#include "log.h" 48#include "main.h" |
|
47#include "id.h" 48 49static int uid; 50static int euid; 51 52void 53ID0init() 54{ --- 115 unchanged lines hidden (view full) --- 170 int ret; 171 172 ID0set0(); 173 ret = uu_unlock(basettyname); 174 LogPrintf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, basettyname); 175 ID0setuser(); 176 return ret; 177} | 49#include "id.h" 50 51static int uid; 52static int euid; 53 54void 55ID0init() 56{ --- 115 unchanged lines hidden (view full) --- 172 int ret; 173 174 ID0set0(); 175 ret = uu_unlock(basettyname); 176 LogPrintf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, basettyname); 177 ID0setuser(); 178 return ret; 179} |
180 181void 182ID0login(struct utmp *ut) 183{ 184 ID0set0(); 185 if (logout(ut->ut_line)) { 186 LogPrintf(LogID0, "logout(\"%s\")\n", ut->ut_line); 187 logwtmp(ut->ut_line, "", ""); 188 LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut->ut_line); 189 } 190 login(ut); 191 LogPrintf(LogID0, "login(\"%s\", \"%.*s\")\n", 192 ut->ut_line, sizeof ut->ut_name, ut->ut_name); 193 ID0setuser(); 194} 195 196void 197ID0logout(const char *device) 198{ 199 struct utmp ut; 200 201 strncpy(ut.ut_line, device, sizeof ut.ut_line - 1); 202 ut.ut_line[sizeof ut.ut_line - 1] = '\0'; 203 204 ID0set0(); 205 if (logout(ut.ut_line)) { 206 LogPrintf(LogID0, "logout(\"%s\")\n", ut.ut_line); 207 logwtmp(ut.ut_line, "", ""); 208 LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut.ut_line); 209 } else 210 LogPrintf(LogERROR, "ID0logout: No longer logged in on %s\n", ut.ut_line); 211 ID0setuser(); 212} |
|