Fossil SCM

Added check of rc for setgid/setuid() calls.

stephan 2012-06-29 21:30 trunk
Commit 4d107b597a4c9eb9db9f76754b069726288762a4
1 file changed +8 -3
+8 -3
--- src/main.c
+++ src/main.c
@@ -24,11 +24,13 @@
2424
#include <time.h>
2525
#include <fcntl.h>
2626
#include <sys/types.h>
2727
#include <sys/stat.h>
2828
#include <stdlib.h> /* atexit() */
29
-
29
+#if !defined(_WIN32)
30
+# include <errno.h> /* errno global */
31
+#endif
3032
#if INTERFACE
3133
#ifdef FOSSIL_ENABLE_JSON
3234
# include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
3335
# include "json_detail.h"
3436
#endif
@@ -1151,12 +1153,15 @@
11511153
zRepo = &zDir[i];
11521154
}
11531155
if( stat(zRepo, &sStat)!=0 ){
11541156
fossil_fatal("cannot stat() repository: %s", zRepo);
11551157
}
1156
- setgid(sStat.st_gid);
1157
- setuid(sStat.st_uid);
1158
+ i = setgid(sStat.st_gid);
1159
+ i = i || setuid(sStat.st_uid);
1160
+ if(i){
1161
+ fossil_fatal("setgid/uid() failed with errno %d", errno);
1162
+ }
11581163
if( g.db!=0 ){
11591164
db_close(1);
11601165
db_open_repository(zRepo);
11611166
}
11621167
}
11631168
--- src/main.c
+++ src/main.c
@@ -24,11 +24,13 @@
24 #include <time.h>
25 #include <fcntl.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdlib.h> /* atexit() */
29
 
 
30 #if INTERFACE
31 #ifdef FOSSIL_ENABLE_JSON
32 # include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
33 # include "json_detail.h"
34 #endif
@@ -1151,12 +1153,15 @@
1151 zRepo = &zDir[i];
1152 }
1153 if( stat(zRepo, &sStat)!=0 ){
1154 fossil_fatal("cannot stat() repository: %s", zRepo);
1155 }
1156 setgid(sStat.st_gid);
1157 setuid(sStat.st_uid);
 
 
 
1158 if( g.db!=0 ){
1159 db_close(1);
1160 db_open_repository(zRepo);
1161 }
1162 }
1163
--- src/main.c
+++ src/main.c
@@ -24,11 +24,13 @@
24 #include <time.h>
25 #include <fcntl.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdlib.h> /* atexit() */
29 #if !defined(_WIN32)
30 # include <errno.h> /* errno global */
31 #endif
32 #if INTERFACE
33 #ifdef FOSSIL_ENABLE_JSON
34 # include "cson_amalgamation.h" /* JSON API. Needed inside the INTERFACE block! */
35 # include "json_detail.h"
36 #endif
@@ -1151,12 +1153,15 @@
1153 zRepo = &zDir[i];
1154 }
1155 if( stat(zRepo, &sStat)!=0 ){
1156 fossil_fatal("cannot stat() repository: %s", zRepo);
1157 }
1158 i = setgid(sStat.st_gid);
1159 i = i || setuid(sStat.st_uid);
1160 if(i){
1161 fossil_fatal("setgid/uid() failed with errno %d", errno);
1162 }
1163 if( g.db!=0 ){
1164 db_close(1);
1165 db_open_repository(zRepo);
1166 }
1167 }
1168

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button