bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gdomap user fix


From: David Ayers
Subject: Re: gdomap user fix
Date: Fri, 05 Sep 2003 19:56:47 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507

Adam Fedor wrote:

+#ifdef __FreeBSD__
+    uid_t      uid = 65534; // setuid(2) expects an unsigned int
+    gid_t      gid = 65534; // dito for getgid(2)
+#else /* __FreeBSD__ */
+    int                uid = -2;
+    int                gid = -2;
+#endif /* __FreeBSD__ */
Just a few minor issues that are unclear to me...

+#ifdef HAVE_PWD_H
+#ifdef HAVE_GETPWNAM
+       const char      *name = "nobody";
+       struct passwd   *pwd;
+
[snip]

+       else // Failed, let's try as a number
+         {
+           long        id;
+           char        *p;
+ + id = strtol(name, &p, 10);

This seems wrong to me. Is there anyway that id can be non-zero given the string "nobody"? Instead should we try the "default" UID for nobody which seems to be 65534 (I'm not sure if some standard specifies this. and maybe all we need to use it the uid/gid values we set up previously.)

+ + if( *name && !*p && (pwd = getpwuid(id)) )

Why check *name? All functions previously using it seem to be declared const char * so the contents must be unchanged.... But if my earlier assertion holds p and potentially name should be obsolete anyway.
[snip]

+ +#if !defined(__svr4__)
+#ifndef __MINGW__
+    strcpy(tmpdir, "/tmp");
+#else
+    if (GetTempPath(1024, tmpdir) == 0)
+      {
+       sprintf(ebuf, "Unable to find temporary dir");
+       gdomap_log(LOG_INFO);
+       tmpdir[0] = '\0';
+      }
+    else
+#endif
+    if (chdir(tmpdir) < 0)
+      {
+       sprintf(ebuf, "Unable to change directory to %s", tmpdir);
+       gdomap_log(LOG_CRIT);
+       exit(EXIT_FAILURE);
+      }
If we exit in the non-MINGW case, why do we continue in the MINGW case? There might be good reason to, as we do have a lot about trouble with home directories which may apply to temp directories also, but a comment would be good.

Cheers,
David






reply via email to

[Prev in Thread] Current Thread [Next in Thread]