Code Duplication    Length = 13-13 lines in 2 locations

PHPDaemon/Thread/IPC.php 2 locations

@@ 145-157 (lines=13) @@
142
            }
143
        }
144
145
        if (isset(Daemon::$config->group->value)) {
146
            if ($sg === false) {
147
                $this->log('Couldn\'t change group to \'' . Daemon::$config->group->value . '\'. You must replace config-variable \'group\' with existing group.');
148
                exit(0);
149
            } elseif (($sg['gid'] != posix_getgid()) && (!posix_setgid($sg['gid']))) {
150
                $this->log('Couldn\'t change group to \'' . Daemon::$config->group->value . "'. Error (" . ($errno = posix_get_last_error()) . '): ' . posix_strerror($errno));
151
                exit(0);
152
            }
153
        }
154
155
        if (isset(Daemon::$config->user->value)) {
156
            if ($su === false) {
157
                $this->log('Couldn\'t change user to \'' . Daemon::$config->user->value . '\', user not found. You must replace config-variable \'user\' with existing username.');
158
                exit(0);
159
            } elseif (($su['uid'] != posix_getuid()) && (!posix_setuid($su['uid']))) {
160
                $this->log('Couldn\'t change user to \'' . Daemon::$config->user->value . "'. Error (" . ($errno = posix_get_last_error()) . '): ' . posix_strerror($errno));
@@ 155-167 (lines=13) @@
152
            }
153
        }
154
155
        if (isset(Daemon::$config->user->value)) {
156
            if ($su === false) {
157
                $this->log('Couldn\'t change user to \'' . Daemon::$config->user->value . '\', user not found. You must replace config-variable \'user\' with existing username.');
158
                exit(0);
159
            } elseif (($su['uid'] != posix_getuid()) && (!posix_setuid($su['uid']))) {
160
                $this->log('Couldn\'t change user to \'' . Daemon::$config->user->value . "'. Error (" . ($errno = posix_get_last_error()) . '): ' . posix_strerror($errno));
161
                exit(0);
162
            }
163
        }
164
165
        if (Daemon::$config->cwd->value !== '.') {
166
            if (!@chdir(Daemon::$config->cwd->value)) {
167
                $this->log('Couldn\'t change directory to \'' . Daemon::$config->cwd->value . '.');
168
            }
169
        }
170
    }