~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to src/gprocess.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2010-08-04 17:17:51 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100804171751-5bvfxhlc5xrmi3n8
Tags: 3.1.2-1
* New upstream release. 
* Update to Standards-Version 3.9.1 .
* Build depend on libcap-dev to add capability support on Linux archs.
* Disable statistics logging (closes: #586749) and restore logging to
  /var/log/syslog .

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <errno.h>
35
35
#include <unistd.h>
36
36
#include <fcntl.h>
37
 
#include <syslog.h>
38
37
#include <termios.h>
39
38
#include <signal.h>
40
39
 
105
104
  GProcessMode mode;
106
105
  const gchar *name;
107
106
  const gchar *user;
108
 
  uid_t uid;
 
107
  gint uid;
109
108
  const gchar *group;
110
 
  gid_t gid;
 
109
  gint gid;
111
110
  const gchar *chroot_dir;
112
111
  const gchar *pidfile;
113
112
  const gchar *pidfile_dir;
700
699
    prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
701
700
#endif
702
701
 
703
 
  if ((gint) process_opts.gid != -1)
 
702
  if (process_opts.gid >= 0)
704
703
    {
705
 
      if (setgid(process_opts.gid) < 0)
 
704
      if (setgid((gid_t) process_opts.gid) < 0)
706
705
        {
707
 
          g_process_message("Error in setgid(); group='%s', gid='%d', error='%s'", process_opts.group, (gint) process_opts.gid, g_strerror(errno));
 
706
          g_process_message("Error in setgid(); group='%s', gid='%d', error='%s'", process_opts.group, process_opts.gid, g_strerror(errno));
708
707
          if (getuid() == 0)
709
708
            return FALSE;
710
709
        }
711
 
      if (process_opts.user && initgroups(process_opts.user, process_opts.gid) < 0)
 
710
      if (process_opts.user && initgroups(process_opts.user, (gid_t) process_opts.gid) < 0)
712
711
        {
713
712
          g_process_message("Error in initgroups(); user='%s', error='%s'", process_opts.user, g_strerror(errno));
714
713
          if (getuid() == 0)
716
715
        }
717
716
    }
718
717
 
719
 
  if ((gint) process_opts.uid != -1)
 
718
  if (process_opts.uid >= 0)
720
719
    {
721
 
      if (setuid(process_opts.uid) < 0)
 
720
      if (setuid((uid_t) process_opts.uid) < 0)
722
721
        {
723
 
          g_process_message("Error in setuid(); user='%s', uid='%d', error='%s'", process_opts.user, (gint) process_opts.uid, g_strerror(errno));
 
722
          g_process_message("Error in setuid(); user='%s', uid='%d', error='%s'", process_opts.user, process_opts.uid, g_strerror(errno));
724
723
          if (getuid() == 0)
725
724
            return FALSE;
726
725
        }
783
782
  if (process_opts.user && !resolve_user(process_opts.user, &process_opts.uid))
784
783
    {
785
784
      g_process_message("Error resolving user; user='%s'", process_opts.user);
786
 
      process_opts.uid = (uid_t) -1;
 
785
      process_opts.uid = -1;
787
786
    }
788
787
  if (process_opts.group && !resolve_group(process_opts.group, &process_opts.gid))
789
788
    {
790
789
      g_process_message("Error resolving group; group='%s'", process_opts.group);
791
 
      process_opts.gid = (gid_t) -1;
 
790
      process_opts.gid = -1;
792
791
    }
793
792
}
794
793