Deleted Added
full compact
systems.c (26516) systems.c (26940)
1/*
2 * System configuration routines
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * System configuration routines
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: systems.c,v 1.11 1997/05/26 00:44:09 brian Exp $
20 * $Id: systems.c,v 1.12 1997/06/09 03:27:38 brian Exp $
21 *
22 * TODO:
23 */
24#include "fsm.h"
25#include "loadalias.h"
26#include "vars.h"
27#include "ipcp.h"
28#include "pathnames.h"
29#include "vars.h"
21 *
22 * TODO:
23 */
24#include "fsm.h"
25#include "loadalias.h"
26#include "vars.h"
27#include "ipcp.h"
28#include "pathnames.h"
29#include "vars.h"
30#include "server.h"
30
31extern void DecodeCommand();
32
33static int uid, gid;
34static int euid, egid;
35static int usermode;
36
37int

--- 13 unchanged lines hidden (view full) ---

51}
52
53static void
54SetUserId()
55{
56 if (!usermode) {
57 if (setreuid(euid, uid) == -1) {
58 LogPrintf(LogERROR, "unable to setreuid!\n");
31
32extern void DecodeCommand();
33
34static int uid, gid;
35static int euid, egid;
36static int usermode;
37
38int

--- 13 unchanged lines hidden (view full) ---

52}
53
54static void
55SetUserId()
56{
57 if (!usermode) {
58 if (setreuid(euid, uid) == -1) {
59 LogPrintf(LogERROR, "unable to setreuid!\n");
60 ServerClose();
59 exit(1);
60 }
61 if (setregid(egid, gid) == -1) {
62 LogPrintf(LogERROR, "unable to setregid!\n");
61 exit(1);
62 }
63 if (setregid(egid, gid) == -1) {
64 LogPrintf(LogERROR, "unable to setregid!\n");
65 ServerClose();
63 exit(1);
64 }
65 usermode = 1;
66 }
67}
68
69static void
70SetPppId()
71{
72 if (usermode) {
73 if (setreuid(uid, euid) == -1) {
74 LogPrintf(LogERROR, "unable to setreuid!\n");
66 exit(1);
67 }
68 usermode = 1;
69 }
70}
71
72static void
73SetPppId()
74{
75 if (usermode) {
76 if (setreuid(uid, euid) == -1) {
77 LogPrintf(LogERROR, "unable to setreuid!\n");
78 ServerClose();
75 exit(1);
76 }
77 if (setregid(gid, egid) == -1) {
78 LogPrintf(LogERROR, "unable to setregid!\n");
79 exit(1);
80 }
81 if (setregid(gid, egid) == -1) {
82 LogPrintf(LogERROR, "unable to setregid!\n");
83 ServerClose();
79 exit(1);
80 }
81 usermode = 0;
82 }
83}
84
85FILE *
86OpenSecret(file)

--- 73 unchanged lines hidden (view full) ---

160 case ' ':
161 case '\t':
162 break;
163 default:
164 wp = strpbrk(cp, ":\n");
165 if (wp == NULL) {
166 LogPrintf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n",
167 filename, linenum);
84 exit(1);
85 }
86 usermode = 0;
87 }
88}
89
90FILE *
91OpenSecret(file)

--- 73 unchanged lines hidden (view full) ---

165 case ' ':
166 case '\t':
167 break;
168 default:
169 wp = strpbrk(cp, ":\n");
170 if (wp == NULL) {
171 LogPrintf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n",
172 filename, linenum);
173 ServerClose();
168 exit(1);
169 }
170 *wp = '\0';
171 if (strcmp(cp, name) == 0) {
172 while (fgets(line, sizeof(line), fp)) {
173 cp = line;
174 if (*cp == ' ' || *cp == '\t') {
175 n = strspn(cp, " \t");

--- 55 unchanged lines hidden ---
174 exit(1);
175 }
176 *wp = '\0';
177 if (strcmp(cp, name) == 0) {
178 while (fgets(line, sizeof(line), fp)) {
179 cp = line;
180 if (*cp == ' ' || *cp == '\t') {
181 n = strspn(cp, " \t");

--- 55 unchanged lines hidden ---