Browse code

call geteuid() instead of getuid()

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@613 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/06/16 05:45:28
Showing 6 changed files
... ...
@@ -1,3 +1,10 @@
1
+Tue Jun 15 22:41:03 CEST 2004 (tk)
2
+----------------------------------
3
+  * clamscan, clamd, freshclam: call geteuid() instead of getuid() to avoid
4
+			error messages when the parent process is running
5
+			with unprivileged effective UID (thanks to Al
6
+			Smith <ajs+clamav*aeschi.ch.eu.org>)
7
+
1 8
 Mon Jun 14 17:38:37 CEST 2004 (tk)
2 9
 ----------------------------------
3 10
   * doc: update
... ...
@@ -199,7 +199,7 @@ void clamd(struct optstruct *opt)
199 199
     }
200 200
 
201 201
     /* drop priviledges */
202
-    if(getuid() == 0 && (cpt = cfgopt(copt, "User"))) {
202
+    if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))) {
203 203
 	if((user = getpwnam(cpt->strarg)) == NULL) {
204 204
 	    fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg);
205 205
 	    logg("!Can't get information about user %s.\n", cpt->strarg);
... ...
@@ -74,7 +74,7 @@ int scanmanager(const struct optstruct *opt)
74 74
 
75 75
 /* njh@bandsman.co.uk: BeOS */
76 76
 #if !defined(C_CYGWIN) && !defined(C_BEOS)
77
-    if(!getuid()) {
77
+    if(!geteuid()) {
78 78
 	if((user = getpwnam(UNPUSER)) == NULL) {
79 79
 	    mprintf("@Can't get information about user "UNPUSER".\n");
80 80
 	    exit(60); /* this is critical problem, so we just exit here */
... ...
@@ -220,7 +220,7 @@ int scanmanager(const struct optstruct *opt)
220 220
 
221 221
 		/* njh@bandsman.co.uk: BeOS */
222 222
 #if !defined(C_CYGWIN) && !defined(C_BEOS)
223
-		if(!getuid()) {
223
+		if(!geteuid()) {
224 224
 		    if((user = getpwnam(UNPUSER)) == NULL) {
225 225
 			mprintf("@Can't get information about user %s\n", UNPUSER);
226 226
 			exit(60); /* this is critical problem, so we just exit here */
... ...
@@ -481,7 +481,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
481 481
 		mprintf("@Can't fork.\n");
482 482
 		exit(61);
483 483
 	    case 0: /* read access denied */
484
-		if(getuid()) {
484
+		if(geteuid()) {
485 485
 		    if(!printinfected)
486 486
 			mprintf("%s: Access denied to archive.\n", filename);
487 487
 		} else {
... ...
@@ -501,7 +501,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
501 501
 	}
502 502
     }
503 503
 
504
-    if(getuid())
504
+    if(geteuid())
505 505
 	if(checkaccess(filename, NULL, R_OK) != 1) {
506 506
 	    if(!printinfected)
507 507
 		mprintf("%s: Access denied.\n", filename);
... ...
@@ -902,7 +902,7 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc
902 902
 	    return -1;
903 903
 	case 0:
904 904
 #ifndef C_CYGWIN
905
-	    if(!getuid() && user) {
905
+	    if(!geteuid() && user) {
906 906
 
907 907
 #ifdef HAVE_SETGROUPS
908 908
 		if(setgroups(1, &user->pw_gid)) {
... ...
@@ -73,7 +73,7 @@ int checkaccess(const char *path, const char *username, int mode)
73 73
 	struct passwd *user;
74 74
 	int ret = 0, status;
75 75
 
76
-    if(!getuid()) {
76
+    if(!geteuid()) {
77 77
 
78 78
 	if((user = getpwnam(username)) == NULL) {
79 79
 	    return -1;
... ...
@@ -156,7 +156,7 @@ int clamav_rmdirs(const char *dir)
156 156
 	    return -1;
157 157
 	case 0:
158 158
 #ifndef C_CYGWIN
159
-	    if(!getuid()) { 
159
+	    if(!geteuid()) { 
160 160
 		if((user = getpwnam(UNPUSER)) == NULL)
161 161
 		    return -3;
162 162
 
... ...
@@ -147,7 +147,7 @@ int freshclam(struct optstruct *opt)
147 147
 	unpuser = UNPUSER;
148 148
     }
149 149
 
150
-    if(!getuid()) {
150
+    if(!geteuid()) {
151 151
 	if((user = getpwnam(unpuser)) == NULL) {
152 152
 	    mprintf("@Can't get information about user %s.\n", unpuser);
153 153
 	    exit(60); /* this is critical problem, so we just exit here */