Commit 0517d806 authored by jan.koester's avatar jan.koester
Browse files

test

parent 86b04fa1
Loading
Loading
Loading
Loading
+1 −9
Changes for src/blogi.cpp: 1 added line, 9 removed lines.
Original line number Diff line number Diff line
@@ -2968,26 +2968,18 @@ public:
                blogi::Blogi blg(getServerSockets(),debug);
                #ifndef Windows
                if(!debug) {
                    // Only drop privileges if we were started as root. When the
                    // service is launched directly as the blogi user (e.g. via
                    // setuidgid) there is nothing to drop and getpwnam_r would
                    // needlessly fail in minimal rootfs setups.
                    if(getuid()==0) {
                        struct passwd pwd_storage;
                        char buffer[1024];
                        struct passwd *result = NULL;

                        const char *username = "blogi";

                        if(getpwnam_r(username, &pwd_storage, buffer, sizeof(buffer), &result)!=0 || result==NULL){
                            throw httpexception[libhttppp::HTTPException::Error] << "can'T change user !";
                            throw httpexception[...] << "can'T change user !";
                        }

                        seteuid(pwd_storage.pw_uid);
                        setegid(pwd_storage.pw_gid);
                    }
                }else{
                    blg.threads=2;
                }
                #endif
                blg.runEventloop();