Switch to unified view

a/src/main.cxx b/src/main.cxx
...
...
463
    }
463
    }
464
    Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
464
    Logger::getTheLog("")->setLogLevel(Logger::LogLevel(loglevel));
465
465
466
    Pidfile pidfile(pidfilename);
466
    Pidfile pidfile(pidfilename);
467
467
468
    // If started by root, do the pidfile + change uid thing
468
    // If started by root, we use the pidfile and we will change the
469
    // uid (later). First part follows
469
    uid_t runas(0);
470
    uid_t runas(0);
470
    gid_t runasg(0);
471
    gid_t runasg(0);
471
    if (geteuid() == 0) {
472
    if (geteuid() == 0) {
472
        struct passwd *pass = getpwnam(upmpdcliuser.c_str());
473
        struct passwd *pass = getpwnam(upmpdcliuser.c_str());
473
        if (pass == 0) {
474
        if (pass == 0) {
...
...
535
        if (!logfilename.empty() && logfilename.compare("stderr")) {
536
        if (!logfilename.empty() && logfilename.compare("stderr")) {
536
            if (chown(logfilename.c_str(), runas, -1) < 0) {
537
            if (chown(logfilename.c_str(), runas, -1) < 0) {
537
                LOGERR("chown("<<logfilename<<") : errno : " << errno << endl);
538
                LOGERR("chown("<<logfilename<<") : errno : " << errno << endl);
538
            }
539
            }
539
        }
540
        }
541
        if (!g_configfilename.empty()) {
542
            ensureconfreadable(g_configfilename.c_str(), upmpdcliuser.c_str(),
543
                               runas, runasg);
544
        }
540
        if (initgroups(upmpdcliuser.c_str(), runasg) < 0) {
545
        if (initgroups(upmpdcliuser.c_str(), runasg) < 0) {
541
            LOGERR("initgroup failed. Errno: " << errno << endl);
546
            LOGERR("initgroup failed. Errno: " << errno << endl);
542
        }
547
        }
543
        if (setuid(runas) < 0) {
548
        if (setuid(runas) < 0) {
544
            LOGFAT("Can't set my uid to " << runas << " current: " << geteuid()
549
            LOGFAT("Can't set my uid to " << runas << " current: " << geteuid()
545
                   << endl);
550
                   << endl);
546
            return 1;
551
            return 1;
547
        }
552
        }
548
#if 0        
553
#if 0
549
        gid_t list[100];
554
        gid_t list[100];
550
        int ng = getgroups(100, list);
555
        int ng = getgroups(100, list);
551
        cerr << "GROUPS: ";
556
        cerr << "GROUPS: ";
552
        for (int i = 0; i < ng; i++) {
557
        for (int i = 0; i < ng; i++) {
553
            cerr << int(list[i]) << " ";
558
            cerr << int(list[i]) << " ";
554
        }
559
        }
555
        cerr << endl;
560
        cerr << endl;
556
#endif
561
#endif
557
    }
562
    }
558
563
559
//// Dropped root 
564
565
/////////////////////////// Dropped root /////////////////////////////
560
566
561
    if (sc2mpdpath.empty()) {
567
    if (sc2mpdpath.empty()) {
562
        // Do we have an sc2mpd command installed (for songcast)?
568
        // Do we have an sc2mpd command installed (for songcast)?
563
        if (!ExecCmd::which("sc2mpd", sc2mpdpath))
569
        if (!ExecCmd::which("sc2mpd", sc2mpdpath))
564
            sc2mpdpath.clear();
570
            sc2mpdpath.clear();