~ubuntu-branches/ubuntu/oneiric/pam/oneiric-proposed

« back to all changes in this revision

Viewing changes to modules/pam_env/pam_env.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-02-17 16:15:47 UTC
  • mfrom: (3.2.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110217161547-afxi0yboxvn18a5t
Tags: 1.1.2-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/libpam-modules.postinst: Add PATH to /etc/environment if it's
    not present there or in /etc/security/pam_env.conf. (should send to
    Debian).
  - debian/libpam0g.postinst: only ask questions during update-manager when
    there are non-default services running.
  - debian/patches-applied/series: Ubuntu patches are as below ...
  - debian/patches-applied/ubuntu-rlimit_nice_correction: Explicitly
    initialise RLIMIT_NICE rather than relying on the kernel limits.
  - Change Vcs-Bzr to point at the Ubuntu branch.
  - debian/patches-applied/pam_motd-legal-notice: display the contents of
    /etc/legal once, then set a flag in the user's homedir to prevent
    showing it again.
  - debian/update-motd.5, debian/libpam-modules.manpages: add a manpage
    for update-motd, with some best practices and notes of explanation.
  - debian/patches/update-motd-manpage-ref: add a reference in pam_motd(8)
    to update-motd(5)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <string.h>
24
24
#include <syslog.h>
25
25
#include <sys/stat.h>
 
26
#include <sys/fsuid.h>
26
27
#include <sys/types.h>
27
28
#include <unistd.h>
28
29
 
772
773
 
773
774
  if(user_readenv && retval == PAM_SUCCESS) {
774
775
    char *envpath = NULL;
775
 
    struct passwd *user_entry;
 
776
    struct passwd *user_entry = NULL;
776
777
    const char *username;
777
778
    struct stat statbuf;
778
779
 
779
780
    username = _pam_get_item_byname(pamh, "PAM_USER");
780
781
 
781
 
    user_entry = pam_modutil_getpwnam (pamh, username);
 
782
    if (username)
 
783
      user_entry = pam_modutil_getpwnam (pamh, username);
782
784
    if (!user_entry) {
783
785
      pam_syslog(pamh, LOG_ERR, "No such user!?");
784
786
    }
789
791
          return PAM_BUF_ERR;
790
792
        }
791
793
      if (stat(envpath, &statbuf) == 0) {
 
794
        uid_t euid = geteuid();
 
795
        setfsuid (user_entry->pw_uid);
792
796
        retval = _parse_config_file(pamh, envpath);
 
797
        setfsuid (euid);
793
798
        if (retval == PAM_IGNORE)
794
799
          retval = PAM_SUCCESS;
795
800
      }