Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message when checking the presence of the "ghost" user is imprecise #1860

Open
4 tasks done
tmlmt opened this issue Aug 4, 2024 · 1 comment
Open
4 tasks done
Labels

Comments

@tmlmt
Copy link

tmlmt commented Aug 4, 2024

Steps to Reproduce

  1. Initiate a ghost instance without systemd unit setup
  2. Change the ownership of the folder and subfolders to simulate wrong ownership
  3. Execute ghost setup systemd

Output

myuser@mymachine:/var/www/tmlmt/blog$ ghost setup systemd

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



The "ghost" user has not been created, try running `ghost setup linux-user` first
ℹ Setting up Systemd [skipped]

Expected behavior

I would expect the systemd step to be executed, not skipped

Analysis

The systemd step checks whether the ghost user exists using the getUid function and checking whether the return value evaluates as false

const uid = getUid(instance.dir);
// getUid returns either the uid or null
if (!uid) {
return task.skip('The "ghost" user has not been created, try running `ghost setup linux-user` first');
}

But that function actually does two things: it returns the uid of the ghost user when it exists, or if returns null if the directory is not owned by that user.

module.exports = function getUid(dir) {
try {
const uid = execa.shellSync('id -u ghost').stdout;
const stat = fs.lstatSync(path.join(dir, 'content'));
if (stat.uid.toString() !== uid) {
// Ghost user is not the owner of this folder, return null
return null;
}

The logic above should probably be changed either to explicitely separate the two distinct checks that are made, so that, in case the directory's ownership is not correct, the message error doesn't refer to the ghost user not existing, when it does.

Technical details

This is automatically output by Ghost-CLI if an error occurs, please copy & paste:

  • OS: Ubuntu 24.04
  • Node Version: 18.20.4
  • Ghost-CLI Version: 1.26.1
  • Environment: bash
  • Command: ghost setup systemd

Bug submission checklist

Please fill out this checklist to acknowledge that you followed the requirements to submit a bug report.

  • Tried to find help in the forum & docs
  • Checked for existing issues
  • Attached log file
  • Provided technical details incl. operating system
Copy link

github-actions bot commented Dec 2, 2024

Our bot has automatically marked this issue as stale because there has not been any activity here in some time. The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR. We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂

@github-actions github-actions bot added the Stale label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant