File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ PREFIX?=/usr/local
5
5
MANDIR? =$(DESTDIR )$(PREFIX ) /man
6
6
SYSCONFDIR? =$(DESTDIR )$(PREFIX ) /etc
7
7
OBJECTS =doas.o env.o execvpe.o reallocarray.o y.tab.o
8
+ OPT? =-O2
8
9
# Can set GLOBAL_PATH here to set PATH for target user.
9
10
# TARGETPATH=-DGLOBAL_PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\"
10
- CFLAGS+ =-DUSE_PAM -DDOAS_CONF=\"${SYSCONFDIR}/doas.conf\" $(TARGETPATH )
11
+ CFLAGS+ =-Wall $( OPT ) - DUSE_PAM -DDOAS_CONF=\"${SYSCONFDIR}/doas.conf\" $(TARGETPATH )
11
12
LDFLAGS+ =-lpam
12
13
UNAME_S := $(shell uname -s)
13
14
ifeq ($(UNAME_S ) ,Linux)
Original file line number Diff line number Diff line change @@ -85,19 +85,25 @@ static int
85
85
parseuid (const char * s , uid_t * uid )
86
86
{
87
87
struct passwd * pw ;
88
- const char * errstr ;
88
+ #if !defined(__linux__ ) && !defined(__NetBSD__ )
89
+ const char * errstr = NULL ;
90
+ #else
91
+ int status ;
92
+ #endif
89
93
90
94
if ((pw = getpwnam (s )) != NULL ) {
91
95
* uid = pw -> pw_uid ;
92
96
return 0 ;
93
97
}
94
98
#if !defined(__linux__ ) && !defined(__NetBSD__ )
95
99
* uid = strtonum (s , 0 , UID_MAX , & errstr );
96
- #else
97
- sscanf (s , "%d" , uid );
98
- #endif
99
100
if (errstr )
100
101
return -1 ;
102
+ #else
103
+ status = sscanf (s , "%d" , uid );
104
+ if (status != 1 )
105
+ return -1 ;
106
+ #endif
101
107
return 0 ;
102
108
}
103
109
@@ -117,19 +123,25 @@ static int
117
123
parsegid (const char * s , gid_t * gid )
118
124
{
119
125
struct group * gr ;
120
- const char * errstr ;
126
+ #if !defined(__linux__ ) && !defined(__NetBSD__ )
127
+ const char * errstr = NULL ;
128
+ #else
129
+ int status ;
130
+ #endif
121
131
122
132
if ((gr = getgrnam (s )) != NULL ) {
123
133
* gid = gr -> gr_gid ;
124
134
return 0 ;
125
135
}
126
136
#if !defined(__linux__ ) && !defined(__NetBSD__ )
127
137
* gid = strtonum (s , 0 , GID_MAX , & errstr );
128
- #else
129
- sscanf (s , "%d" , gid );
130
- #endif
131
138
if (errstr )
132
139
return -1 ;
140
+ #else
141
+ status = sscanf (s , "%d" , gid );
142
+ if (status != 1 )
143
+ return -1 ;
144
+ #endif
133
145
return 0 ;
134
146
}
135
147
You can’t perform that action at this time.
0 commit comments