OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /v/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   13-Sep-2006 16:46:26
  Branch: HEAD                             Handle: 2006091315462401

  Modified files:
    openpkg-src/openpkg     HISTORY openpkg.c

  Log:
    if CWD is NO LONGER accessible, try to switch to home of target
    identity to prevent failures in e.g. GNU bash

  Summary:
    Revision    Changes     Path
    1.374       +1  -0      openpkg-src/openpkg/HISTORY
    1.3         +12 -0      openpkg-src/openpkg/openpkg.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/HISTORY
  ============================================================================
  $ cvs diff -u -r1.373 -r1.374 HISTORY
  --- openpkg-src/openpkg/HISTORY       13 Sep 2006 13:57:58 -0000      1.373
  +++ openpkg-src/openpkg/HISTORY       13 Sep 2006 14:46:24 -0000      1.374
  @@ -2,6 +2,7 @@
   2006
   ====
   
  +20060913 if CWD is NO LONGER accessible, try to switch to home of target 
identity to prevent failures in e.g. GNU bash
   20060913 unpack source RPM package files as management user if called by 
super user ("openpkg rpm -Uvh *.src.rpm")
   20060913 do not rise privileges for "openpkg rc" when given --eval or 
--print options
   20060910 OpenPKG supports all major Unix platforms - remove explicit and 
unmaintained platform support determination
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/openpkg.c
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 openpkg.c
  --- openpkg-src/openpkg/openpkg.c     13 Sep 2006 10:42:22 -0000      1.2
  +++ openpkg-src/openpkg/openpkg.c     13 Sep 2006 14:46:25 -0000      1.3
  @@ -125,6 +125,7 @@
   static void adjust_privileges(uid_t uid, gid_t gid, int login)
   {
       struct passwd *pw;
  +    char cwd[MAXPATHLEN];
   
       /* optionally emulate a more complete login */
       if (login) {
  @@ -153,6 +154,17 @@
       if (setuid(uid) == -1)
           fatal("failed to set user id via setuid(2): %s", strerror(errno));
   
  +    /* in case the current working directory is NO LONGER accessible,
  +       try to switch to the home directory of the target identity to
  +       prevent failures in subsequently called programs (e.g. GNU bash) */
  +    if (login) {
  +        if (getcwd(cwd, sizeof(cwd)) == NULL) {
  +            warn("current working directory is no longer accessible -- 
switching to \"%s\"", pw->pw_dir);
  +            if (chdir(pw->pw_dir) == -1)
  +                fatal("unable to chdir(2) to \"%s\": %s", pw->pw_dir, 
strerror(errno));
  +        }
  +    }
  +
       return;
   }
   
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     openpkg-cvs@openpkg.org

Reply via email to