[patch]: gdomap.c getuid usage
Fixes a MINGW compilation problem. Commited to both branches... 2003-09-01 Adam Fedor <[EMAIL PROTECTED]> * Tools/gdomap.c (main): Move getuid call inside #ifndef MINGW like the others. Index: Tools/gdomap.c === RCS file: /cvsroot/gnustep/gnustep/core/base/Tools/gdomap.c,v retrieving revision 1.74 diff -u -p -r1.74 gdomap.c --- Tools/gdomap.c 6 Aug 2003 05:39:51 - 1.74 +++ Tools/gdomap.c 2 Sep 2003 02:31:27 - @@ -4654,14 +4654,14 @@ printf( setgid (gid); setgroups (0, 0);/* Empty additional groups list */ } -#endif /* __MINGW__ */ - if (getuid() == 0) { sprintf(ebuf, "Still running as root after trying to change"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } + +#endif /* __MINGW__ */ init_probe();/* Probe other name servers on net. */ ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep
[RFC]: More automatic timezone info.
This patches NSTimeZone to use a more standard (Posix?) method of finding the time zone info that's already set on the computer. I think many people could avoid having to set the "Local Time Zone" default. 2003-09-01 Adam Fedor <[EMAIL PROTECTED]> * configure.ac: Check for tzset * Source/NSTimeZone.m (+systemTimeZone): Use it to find time zone (as a last resort). Index: configure.ac === RCS file: /cvsroot/gnustep/gnustep/core/base/configure.ac,v retrieving revision 1.26 diff -u -p -r1.26 configure.ac --- configure.ac24 Aug 2003 02:46:30 - 1.26 +++ configure.ac2 Sep 2003 02:47:57 - @@ -529,7 +529,7 @@ LIBS="$saved_LIBS" dnl AC_REPLACE_FUNCS(getrusage gettimeofday) AC_CHECK_HEADERS(time.h sys/time.h sys/rusage.h ucbinclude/sys/resource.h) -AC_CHECK_FUNCS(time ctime) +AC_CHECK_FUNCS(time ctime tzset) # # These headers/functions needed by GSTcpPort.m Index: Headers/Additions/GNUstepBase/config.h.in === RCS file: /cvsroot/gnustep/gnustep/core/base/Headers/Additions/GNUstepBase/config.h.in,v retrieving revision 1.1 diff -u -p -r1.1 config.h.in --- Headers/Additions/GNUstepBase/config.h.in 31 Jul 2003 23:49:29 - 1.1 +++ Headers/Additions/GNUstepBase/config.h.in 2 Sep 2003 02:47:58 - @@ -6,7 +6,7 @@ /* Define if SO_REUSEADDR is broken on this system */ #undef BROKEN_SO_REUSEADDR -/* Define if your system terminates the final argument in /proc/28891/cmdline */ +/* Define if your system terminates the final argument in /proc/$$/cmdline */ #undef CMDLINE_TERMINATED /* Define if constructors are automatically loaded */ @@ -121,6 +121,9 @@ /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP +/* Define to 1 if you have the `nanosleep' function. */ +#undef HAVE_NANOSLEEP + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H @@ -282,6 +285,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TIME_H +/* Define to 1 if you have the `tzset' function. */ +#undef HAVE_TZSET + /* Define to 1 if you have the header file. */ #undef HAVE_UCBINCLUDE_SYS_RESOURCE_H @@ -290,9 +296,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H - -/* Define to 1 if you have the `nanosleep' function. */ -#undef HAVE_NANOSLEEP /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP Index: Source/NSTimeZone.m === RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSTimeZone.m,v retrieving revision 1.56 diff -u -p -r1.56 NSTimeZone.m --- Source/NSTimeZone.m 31 Jul 2003 23:49:31 - 1.56 +++ Source/NSTimeZone.m 2 Sep 2003 02:47:59 - @@ -54,6 +54,7 @@ #include #include #include +#include #include "Foundation/NSArray.h" #include "Foundation/NSCoder.h" #include "Foundation/NSData.h" @@ -1123,6 +1124,18 @@ static NSMapTable*absolutes = 0; localZoneString = [localZoneString stringByTrimmingSpaces]; } } +#if HAVE_TZSET + if (localZoneString == nil) + { + /* + * Try to get timezone from tzset and tzname + */ + extern char *tzname[2]; + tzset(); + if (tzname[0] != NULL && *tzname[0] != '\0') + localZoneString = [NSString stringWithCString: tzname[0]]; + } +#else if (localZoneString == nil) { /* @@ -1131,6 +1144,7 @@ static NSMapTable *absolutes = 0; localZoneString = [[[NSProcessInfo processInfo] environment] objectForKey: @"TZ"]; } +#endif if (localZoneString != nil) { zone = [defaultPlaceholderTimeZone initWithName: localZoneString]; ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep
Re: [bug #4658] Broken gpbs when doing pb operations between GS andX
Fred Kiefer wrote: I did my orignal copying from the UTF8 page with konqueror, which does not have this problem, doing it with Mozilla showed that we still need to support more of the X selection interface. The error I do get here is a bit clearer than the one you list: Unsupported data type 'INCR' from X selection. And INCR is a rather complex X selection transfer mode, which really has not been implemented up to now (Checkout section 2.7.2 of the ICCCM standard). I may look into this later on, but any help here is really appreciated. > Ok, as nobody did step up I tried it myself and lets all have a look at the results. First the good news: GNUstep now supports the INCR transfer for the X selection (and a lot more smaller ICCCM stuff was added in the same go). But there is of course also a bit of bad news, which is that this specific page still cannot be transfered, which is according to my findings caused by the Unicode conversion inside of NSString which fails. This may be a bug or caused by the fact that this page includes characters that cannot be expressed as UCS-2. This is a known limitation of our current NSString implementation. There is of course still plenty of room for improvements on xpbs... For now please test again, but remember there is a lot more that may go wrong when no paste result shows up than just the X selection interaction. Fred ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep
Re: gdomap user fix
On Mon, 2003-08-25 at 14:22, Chris B. Vetter wrote: > Hi, > > attached is a modified version of the patch I sent last week that > finally takes care of the UID and GID retrieval, by trying to get that > information BEFORE jail'ing gdomap to /tmp. > I had to apply the patch by hand, so I'm not sure I did it right. Here's another updated patch. I changed a few things and also added a fix for changing to /tmp on MinGW. Can you check if this is ok? I'd still like to get comments from other people as well, though, before I commit it. Index: Tools/gdomap.c === RCS file: /cvsroot/gnustep/gnustep/core/base/Tools/gdomap.c,v retrieving revision 1.75 diff -u -p -r1.75 gdomap.c --- Tools/gdomap.c 2 Sep 2003 02:44:15 - 1.75 +++ Tools/gdomap.c 3 Sep 2003 03:30:41 - @@ -823,7 +823,7 @@ static unsigned long prb_used = 0; static unsigned long prb_size = 0; typedef struct { struct in_addr sin; - long when; + time_t when; } prb_type; static prb_type **prb = 0; @@ -4598,27 +4598,119 @@ printf( #endif } -#if !defined(__svr4__) /* * As another level of paranoia - restrict this process to /tmp */ - if (chdir("/tmp") < 0) -{ - sprintf(ebuf, "Unable to change directory to /tmp"); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); -} + + { +char tmpdir[1024]; +// +// Try to get the UID and GID first +// + #ifndef __MINGW__ - if (geteuid() == 0) -{ - if (chroot("/tmp") < 0) - { - sprintf(ebuf, "Unable to change root to /tmp"); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); - } - chdir("/"); -} +#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__ */ + +/* + * If we are not 'root' simply use our own UID and GID so we can + * later kill it again if needed + */ + +if( getuid() != 0 ) + { + uid = getuid(); + gid = getgid(); + } +else // gdomap runs as 'root' so we try to switch to 'nobody' + { +#ifdef HAVE_PWD_H +#ifdef HAVE_GETPWNAM + const char *name = "nobody"; + struct passwd *pwd; + +#ifdef __FreeBSD__ + // rewind the PWD database to the beginning and make sure it says open + setpassent(1); +#endif + + /* + * Translate name into a PWD pointer + */ + + pwd = (struct passwd *) getpwnam(name); + + if( pwd ) + { + uid = pwd->pw_uid; + gid = pwd->pw_gid; + } + else // Failed, let's try as a number + { + long id; + char *p; + + id = strtol(name, &p, 10); + + if( *name && !*p && (pwd = getpwuid(id)) ) + { + uid = pwd->pw_uid; + gid = pwd->pw_gid; + } + else // Failed as well, dump a warning + { + sprintf(ebuf, "Cannot get UID and GID, assuming default values."); + gdomap_log(LOG_WARNING); + } + } +#ifdef __FreeBSD__ + // close the PWD database + endpwent(); +#endif /* __FreeBSD__ */ +#endif /* HAVE_GETPWNAM */ +#endif /* HAVE_PWD_H */ + } +#endif /* __MINGW__ */ + +/* + * Now that we got the UID and GID, we can jail gdomap to /tmp + */ + +#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); + } + +#ifndef __MINGW__ +if (geteuid() == 0) + { + if (chroot(tmpdir) < 0) + { + sprintf(ebuf, "Unable to change root to %s", tmpdir); + gdomap_log(LOG_CRIT); + exit(EXIT_FAILURE); + } + chdir("/"); + } #endif /* __MINGW__ */ #endif /* __svr4__ */ @@ -4627,33 +4719,28 @@ printf( * Try to become a 'safe' user now that we have * done everything that needs root priv. */ - if (getuid () != 0) -{ - /* - * Try to be the user who launched us ... so they can kill us too. - */ - setuid (getuid ()); - setgid (getgid ()); -} - else -{ - int uid = -2; - int gid = -2; -#ifdef HAVE_PWD_H -#ifdef HAVE_GETPWNAM - struct passwd *pw = getpwnam("nobody"); - - if (pw != 0) - { - uid = pw->pw_uid; - gid = pw->pw_gid; - } -#endif -#endif - setuid (uid); - setgid (gid); - setgroups (0, 0); /* Empty additional groups list */ -} +if (getuid () != 0) + { + /* + * On FreeBSD, setgroups(2) only works correctly for root, therefor + * we clear the group access list before the actual switch and dump + * a warning if it fails + */ + + errno = 0; + + if( setgroups (0, NULL) < 0 ) + { + sprintf(ebuf, "Cannot clear the group access list: %s", + strerror(errno)); + gdomap_log(
Re: [bug #4658] Broken gpbs when doing pb operations between GS andX
> First the good news: GNUstep now supports the INCR transfer for the X > selection (and a lot more smaller ICCCM stuff was added in the same go). Excellent stuff. > But there is of course also a bit of bad news, which is that this > specific page still cannot be transfered, which is according to my > findings caused by the Unicode conversion inside of NSString which A... now is this related to the other "bug" we were talking about before I left -- i.e. the one where valid UTF-8 sequences outside the BMP cause the conversion to fail ? If so then I am halfway to a solution for this which involves re-writing the conversion code to convert it into UTF-16, which is the behaviour of OS X. I havent submitted a patch yet as its not finished (am trying to make it match OSX as closely as possible) but will that fix this problem ? > For now please test again, but remember there is a lot more that may go > wrong when no paste result shows up than just the X selection interaction. O.K., will do, and thanks... -bat. ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep
Re: make bug
Thanks Matt, sorry for the delay in answering. > I noticed that ADDITIONAL_INSTALL_DIRS seems to be > documented as a global variable but only seems to be > used by libraries... Good spot. I've added it on CVS (head branch only). > additionally I was thinking it might be nice have in > common.make something to the effect of... > GNUSTEP_APPLICATIONSUPPORT=$(GNUSTEP_LIBRARY)/ApplicationSupport Thanks - it seems a reasonable suggestion given that gnustep-base has support for GSApplicationSupportDirectory which looks for that directory. I've added it (with name GNUSTEP_APPLICATION_SUPPORT) on CVS (head branch only). ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep
Re: Gorm build problem
Steve, Gorm 0.3.0 will not build with the latest version of core. The older templates have been removed.I would recommend using the latest version of Gorm which is available on the website Gorm-0.3.1. It is much more stable than 0.3.0. Thanks, GJC --- Steve Wainstead <[EMAIL PROTECTED]> wrote: > > I'm getting this error when trying to build Gorm 0.3.0: > > In file included from main.m:26: > ../../GormPrivate.h:69: cannot find interface declaration for > `NSViewTemplate' > make[3]: *** [shared_obj/main.o] Error 1 > make[2]: *** [1Windows.all.palette.variables] Error 2 > make[2]: Leaving directory > `/home/swain/gnustep/Gorm-0.3.0/Palettes/1Windows' > make[1]: *** [internal-all] Error 2 > make[1]: Leaving directory `/home/swain/gnustep/Gorm-0.3.0/Palettes' > make: *** [internal-all] Error 2 > > > The interface NSViewTemplate was apparently in gnustep-gui at some point; > according to the ChangeLog for gnustep-gui: > > 2002-10-06 Gregory John Casamento <[EMAIL PROTECTED]> > > * Source/NSBundleAdditions.m: Implemented the following classes: > NSWindowTemplate, NSViewTemplate, NSControlTemplate, > NSTextTemplate, > NSTextViewTemplate, NSMenuTemplate, GSClassSwapper. These > classes > are used to allow the .gorm files to have placeholders for custom > classes defined by the developer. This is similar to the > approach > used in OPENSTEP 4.2/Mach and MOSX. > > > > I am using a Red Hat 9.0 system (upgraded from 8.1), and I installed the > following: > > gnustep-back-0.8.9.tar.gz gnustep-examples-0.9.7.tar.gz > gnustep-make-1.7.3.tar.gz > gnustep-base-1.7.3.tar.gz gnustep-gui-0.8.9.tar.gz > Gorm-0.3.0.tar.gz > > I am able to run the gnustep-examples just fine. > > cheers, > ~swain > > > > http://www.panix.com/~swain/ > "It has all the faults of a photograph." -- David Hockney > > > > ___ > Bug-gnustep mailing list > [EMAIL PROTECTED] > http://mail.gnu.org/mailman/listinfo/bug-gnustep = Gregory John Casamento -- bheron on #gnustep, #linuxstep, & #gormtalk Please sign the petition against software patents at: http://www.petitiononline.com/pasp01/petition.html Petition to make Lighthouse Application Suite Free Software at: http://www.petitiononline.com/laafs/petition.html --- Main Developer of Gorm (featured in April Linux Journal) --- __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com ___ Bug-gnustep mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-gnustep