Deleted Added
full compact
systems.c (22997) systems.c (25630)
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$
20 * $Id: systems.c,v 1.9 1997/02/22 16:10:56 peter Exp $
21 *
22 * TODO:
23 */
24#include "fsm.h"
25#include "vars.h"
26#include "ipcp.h"
27#include "pathnames.h"
28#include "vars.h"

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

42 egid = getegid();
43 usermode = 0;
44}
45
46static void
47SetUserId()
48{
49 if (!usermode) {
21 *
22 * TODO:
23 */
24#include "fsm.h"
25#include "vars.h"
26#include "ipcp.h"
27#include "pathnames.h"
28#include "vars.h"

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

42 egid = getegid();
43 usermode = 0;
44}
45
46static void
47SetUserId()
48{
49 if (!usermode) {
50 setreuid(euid, uid);
51 setregid(egid, gid);
50 if (setreuid(euid, uid) == -1) {
51 logprintf("unable to setreuid!\n");
52 exit(1);
53 }
54 if (setregid(egid, gid) == -1) {
55 logprintf("unable to setregid!\n");
56 exit(1);
57 }
52 usermode = 1;
53 }
54}
55
56static void
57SetPppId()
58{
59 if (usermode) {
58 usermode = 1;
59 }
60}
61
62static void
63SetPppId()
64{
65 if (usermode) {
60 setreuid(uid, euid);
61 setregid(gid, egid);
66 if (setreuid(uid, euid) == -1) {
67 logprintf("unable to setreuid!\n");
68 exit(1);
69 }
70 if (setregid(gid, egid) == -1) {
71 logprintf("unable to setregid!\n");
72 exit(1);
73 }
62 usermode = 0;
63 }
64}
65
66FILE *
67OpenSecret(file)
68char *file;
69{

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

105char *file;
106{
107 FILE *fp;
108 char *cp, *wp;
109 int n;
110 int val = -1;
111 u_char olauth;
112 char line[200];
74 usermode = 0;
75 }
76}
77
78FILE *
79OpenSecret(file)
80char *file;
81{

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

117char *file;
118{
119 FILE *fp;
120 char *cp, *wp;
121 int n;
122 int val = -1;
123 u_char olauth;
124 char line[200];
125 char filename[200];
126 int linenum;
113
114 fp = NULL;
115 cp = getenv("HOME");
116 if (cp) {
117 SetUserId();
127
128 fp = NULL;
129 cp = getenv("HOME");
130 if (cp) {
131 SetUserId();
118 snprintf(line, sizeof line, "%s/.%s", cp, file);
119 fp = fopen(line, "r");
132 snprintf(filename, sizeof filename, "%s/.%s", cp, file);
133 fp = fopen(filename, "r");
120 }
121 if (fp == NULL) {
122 SetPppId(); /* fix from pdp@ark.jr3uom.iijnet.or.jp */
134 }
135 if (fp == NULL) {
136 SetPppId(); /* fix from pdp@ark.jr3uom.iijnet.or.jp */
123 snprintf(line, sizeof line, "%s/%s", _PATH_PPP, file);
124 fp = fopen(line, "r");
137 snprintf(filename, sizeof filename, "%s/%s", _PATH_PPP, file);
138 fp = fopen(filename, "r");
125 }
126 if (fp == NULL) {
127#ifdef DEBUG
139 }
140 if (fp == NULL) {
141#ifdef DEBUG
128 fprintf(stderr, "can't open %s.\n", line);
142 fprintf(stderr, "can't open %s.\n", filename);
129#endif
130 SetPppId();
131 return(-1);
132 }
133#ifdef DEBUG
143#endif
144 SetPppId();
145 return(-1);
146 }
147#ifdef DEBUG
134 fprintf(stderr, "checking %s (%s).\n", name, line);
148 fprintf(stderr, "checking %s (%s).\n", name, filename);
135#endif
149#endif
150
151 linenum = 0;
136 while (fgets(line, sizeof(line), fp)) {
152 while (fgets(line, sizeof(line), fp)) {
153 linenum++;
137 cp = line;
138 switch (*cp) {
139 case '#': /* comment */
140 break;
141 case ' ':
142 case '\t':
143 break;
144 default:
145 wp = strpbrk(cp, ":\n");
154 cp = line;
155 switch (*cp) {
156 case '#': /* comment */
157 break;
158 case ' ':
159 case '\t':
160 break;
161 default:
162 wp = strpbrk(cp, ":\n");
163 if (wp == NULL) {
164 fprintf(stderr, "Bad rule in %s (line %d) - missing colon.\n",
165 filename, linenum);
166 exit(1);
167 }
146 *wp = '\0';
147 if (strcmp(cp, name) == 0) {
148 while (fgets(line, sizeof(line), fp)) {
149 cp = line;
150 if (*cp == ' ' || *cp == '\t') {
151 n = strspn(cp, " \t");
152 cp += n;
153#ifdef DEBUG

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

191
192 if (SelectSystem(name, CONFFILE) < 0) {
193 printf("%s: not found.\n", name);
194 return(-1);
195 }
196 return(1);
197}
198
168 *wp = '\0';
169 if (strcmp(cp, name) == 0) {
170 while (fgets(line, sizeof(line), fp)) {
171 cp = line;
172 if (*cp == ' ' || *cp == '\t') {
173 n = strspn(cp, " \t");
174 cp += n;
175#ifdef DEBUG

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

213
214 if (SelectSystem(name, CONFFILE) < 0) {
215 printf("%s: not found.\n", name);
216 return(-1);
217 }
218 return(1);
219}
220
199extern struct in_addr ifnetmask;
200
201int
202SaveCommand(list, argc, argv)
203struct cmdtab *list;
204int argc;
205char **argv;
206{
207 printf("save command is not implemented (yet).\n");
208 return(1);
209}
221int
222SaveCommand(list, argc, argv)
223struct cmdtab *list;
224int argc;
225char **argv;
226{
227 printf("save command is not implemented (yet).\n");
228 return(1);
229}