fs.lstat(configstore).then((stats) => { if (stats.uid === process.getuid() && stats.gid === process.getgid()) { return; } const {USER} = process.env; return ui.sudo(`chown -R ${USER}:${USER} ${configstore}`); })
const shouldUseGhostUser = function shouldUseGhostUser(contentDir) { if (os.platform() !== 'linux') { return false; } // get the ghost uid and gid const ghostUser = getGhostUid(); if (!ghostUser) { return false; } const stats = fs.lstatSync(contentDir); if (stats.uid !== ghostUser.uid && stats.gid !== ghostUser.gid) { return false; } return process.getuid() !== ghostUser.uid; }
function loggedInUserOwner(ctx) { // TODO: switch to require('os').userInfo() and output username in errors const uid = process.getuid(); const gid = process.getgroups(); const dir = process.cwd(); const dirStats = fs.lstatSync(path.join(dir)); // check if the current user is the owner of the current dir if (dirStats.uid !== uid) { if (gid.indexOf(dirStats.gid) < 0) { throw new errors.SystemError({ message: `Your user does not own the directory ${dir} and is also not a member of the owning group. You must either log in with the user that owns the directory or add your user to the owning group.`, help: `${chalk.green('https://ghost.org/docs/install/ubuntu/#create-a-new-user-')}`, task: taskTitle }); } // Yup current user is not the owner, but in the same group, so just show a warning ctx.ui.log(`Your user does not own the directory ${dir}. This might cause permission issues.`, 'yellow'); } }