~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to exec/mainconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Loschwitz
  • Date: 2011-10-19 14:32:18 UTC
  • mfrom: (1.1.6 upstream) (5.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20111019143218-ew8phl0raqyog844
Tags: 1.4.2-1
* Changed my email address in debian/control
* Add corosync-blackbox to the corosync package
* Imported Upstream version 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <string.h>
40
40
#include <stdlib.h>
41
41
#include <errno.h>
 
42
#include <unistd.h>
42
43
#include <sys/socket.h>
43
44
#include <netinet/in.h>
44
45
#include <arpa/inet.h>
568
569
 
569
570
static int uid_determine (const char *req_user)
570
571
{
 
572
        int pw_uid = 0;
571
573
        struct passwd passwd;
572
574
        struct passwd* pwdptr = &passwd;
573
575
        struct passwd* temp_pwd_pt;
574
 
        char pwdbuffer[200];
575
 
        int  pwdlinelen = sizeof(pwdbuffer);
 
576
        char *pwdbuffer;
 
577
        int  pwdlinelen;
 
578
 
 
579
        pwdlinelen = sysconf (_SC_GETPW_R_SIZE_MAX);
 
580
 
 
581
        if (pwdlinelen == -1) {
 
582
                pwdlinelen = 256;
 
583
        }
 
584
 
 
585
        pwdbuffer = malloc (pwdlinelen);
576
586
 
577
587
        if ((getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen, &temp_pwd_pt)) != 0) {
578
588
                log_printf (LOGSYS_LEVEL_ERROR,
580
590
                        req_user);
581
591
                corosync_exit_error (AIS_DONE_UID_DETERMINE);
582
592
        }
 
593
        pw_uid = passwd.pw_uid;
 
594
        free (pwdbuffer);
583
595
 
584
 
        return passwd.pw_uid;
 
596
        return pw_uid;
585
597
}
586
598
 
587
599
static int gid_determine (const char *req_group)
590
602
        struct group group;
591
603
        struct group * grpptr = &group;
592
604
        struct group * temp_grp_pt;
593
 
        char grpbuffer[200];
594
 
        int  grplinelen = sizeof(grpbuffer);
 
605
        char *grpbuffer;
 
606
        int  grplinelen;
 
607
 
 
608
        grplinelen = sysconf (_SC_GETGR_R_SIZE_MAX);
 
609
 
 
610
        if (grplinelen == -1) {
 
611
                grplinelen = 256;
 
612
        }
 
613
 
 
614
        grpbuffer = malloc (grplinelen);
595
615
 
596
616
        if ((getgrnam_r (req_group, grpptr, grpbuffer, grplinelen, &temp_grp_pt)) != 0) {
597
617
                log_printf (LOGSYS_LEVEL_ERROR,
600
620
                corosync_exit_error (AIS_DONE_GID_DETERMINE);
601
621
        }
602
622
        ais_gid = group.gr_gid;
 
623
        free (grpbuffer);
 
624
 
603
625
        return ais_gid;
604
626
}
605
627
 
614
636
                /*
615
637
                 * Reload the logsys configuration
616
638
                 */
617
 
                logsys_format_set(NULL);
 
639
                if (logsys_format_set(NULL) == -1) {
 
640
                        fprintf (stderr, "Unable to setup logging format.\n");
 
641
                }
618
642
                corosync_main_config_read_logging(global_objdb,
619
643
                                                  &error_string);
620
644
        }