GoAdmio

fix

Reset ownership and permissions for one account or all accounts, and set an account's permission mode (755, 777, or 555)

On this page: Overview · Quick start · Syntax · Arguments · Permission modes · Output · Examples · Troubleshooting · Details · See also


Overview

/go/fix puts file ownership and permissions back to what GoAdmio expects. For each account it:

It then fixes the server-wide folders that GoAdmio uses and runs session.

Other commands call it after they change accounts, for example create, password, and snapshot restores.

[!WARNING] Several lines in this script need attention before you rely on it. See Notes for maintainers.


Quick start

# Fix one account
/go/fix example.com

# Fix every account
/go/fix all

Syntax

/go/fix [domain|all] [mode]
Form Behavior
/go/fix or /go/fix all Fixes every folder in /home, using each account's saved permission mode.
/go/fix <domain> Fixes one account, using its saved mode.
/go/fix <domain> <mode> Saves the mode (777, 755, or 555) for the account, then fixes it.
/go/fix all <mode> Saves the mode for every account, then fixes all of them.

A mode that is not 777, 755, or 555 is silently ignored. The mode must come second. /go/fix 755 looks for a domain named 755 and prints FIX: Domain Directory /home/755 not Exists.


Arguments

Argument Required Default Notes
[domain|all] No all The account's primary domain, or all.
[mode] No The account's saved mode 777, 755, or 555. It is stored in the panel, so it stays in effect for later runs.

The command has no --option flags.


Permission modes

The mode only changes the files and folders inside www.

Mode Owner of www Folders Files Notes
755 (default; also used for any unrecognized stored value) The account user 755 644 Normal setting.
777 The account user 777 777 Everything is writable and executable by every user on the server. Use only briefly, for debugging.
555 root 555 555 Read-only for the site. Uploads, caches, and updates stop working.

[!WARNING] /go/fix all 777 makes every file of every site writable by every account on the server. Don't use it on a shared server.


Output

Outcome What you get
Account fixed Checking <domain> (<username>) [<mode>]...
FTP account fixed Checking FTP <user> (Directory: <directory>)...
Account folder not found FIX: Domain Directory /home/<name> not Exists

Accounts without a www folder are skipped without a message. The Checking lines end with spaces so that they overwrite a previous line in a terminal. The exit code is always 0.

Logging

Every run is appended to /var/log/go/fix.log.


Examples

# Fix one account with its saved mode
/go/fix example.com
# Set an account back to the normal mode
/go/fix example.com 755
# Make one account read-only
/go/fix example.com 555
# Fix every account
/go/fix all

Troubleshooting

Symptom Likely cause Fix
FIX: Domain Directory /home/755 not Exists The mode was given first. Put the domain first: /go/fix <domain> 755, or /go/fix all 755.
A site can't save uploads, caches, or updates The account is in 555 mode. Run /go/fix <domain> 755.
Files whose names contain spaces keep their old permissions The file list is passed to chmod without handling spaces, and errors are hidden. Rename the files, or fix them by hand.
Scripts lost their executable bit, or private files became readable In 755 mode all files are set to 644. Set the needed modes again after fix.
fix takes very long It changes every file of every account. Fix one domain, or run /go/fix all at a quiet time.
SFTP login fails with a bad ownership error /home/<domain> must be owned by root and not writable by others. Run /go/fix <domain>. If an FTP account's directory is the account root, correct that account first.
FTP user's folder is owned by the FTP user, and the site can't write there FTP accounts whose directory is outside www get ownership of it. Move the FTP directory inside www, or accept that the site's user needs group write access.
chown: cannot access '/usr/local/goadmio/includes' That folder doesn't exist. See Notes for maintainers. Report it to the maintainers.

Details

What it does

  1. Re-runs itself with sudo if not root, and logs the call.
  2. For each account (all of /home, or the one you named):
    1. If <mode> is 777, 755, or 555, saves it as the account's permission mode.
    2. If /home/<domain>/www exists, prints the Checking line and sets the owners and modes in the table below.
    3. For each FTP account of the domain, if its directory does not end in /www, makes the FTP user the owner of that directory, recursively.
  3. Sets /tmp and /tmp/s3 to 777, and /home to 711.
  4. Gives the user go ownership of /var/lib/sqlite and /var/log/go.
  5. Runs a chown 555 on /usr/local/goadmio/includes, and sets /usr/local/goadmio/home/phpmyadmin/config.inc.php to 775.
  6. Runs session.

What is set for each account

Path Owner Mode
/home/<domain> root:root (needed for SFTP) 711
/home/<domain>/www Account user (root in 555 mode) See Permission modes
/home/<domain>/log Account user Not changed
/home/<domain>/mail vmail:vmail 755, recursively
/home/<domain>/sqlite Account user 755, recursively
/home/<domain>/.trash Account user 755, recursively
/var/cache/<domain> Account user 755, recursively
/backup/<domain> Account user 755

Missing folders in this table are created first.

flowchart TD
    A["fix domain mode"] --> B{"Domain or all"}
    B --> C["For each account"]
    C --> D["Save mode if 777, 755, or 555"]
    D --> E{"www exists?"}
    E -- "Yes" --> F["Create folders, set owners and modes"]
    E -- "No" --> G["Skip"]
    F --> H["FTP accounts: chown their directory"]
    G --> H
    H --> I["Server folders, phpMyAdmin config, session"]

Notes for maintainers

Issue Why it matters Suggested fix
chown 555 -R /usr/local/goadmio/includes chown reads 555 as a user ID, so it makes UID 555 the owner and doesn't change the mode. The folder name also differs from /usr/local/goadmio/include/ used elsewhere. Probably meant chmod -R 555. Check the folder name.
chmod 777 /tmp (the comment says 1777) Without the sticky bit, any user can delete or rename other users' temporary files. Use chmod 1777 /tmp, and the same for /tmp/s3.
chmod 755 -R /home/<domain>/mail Mail folders and files become readable by every user on the server, and files become executable. Use owner-only access, for example chmod -R u=rwX,go= ... for vmail.
find ... | xargs chmod without -print0, with errors hidden Files with spaces or newlines in their names keep their old modes, with no message. Use find ... -exec chmod ... {} +.
An FTP account's directory from the database is used as-is and unquoted A directory such as the account root or mail is recursively handed to the FTP user, breaking SFTP and mail ownership. Spaces split the value. Check that the directory is inside /home/<domain>/www, quote it, and read the list line by line.
FTP ownership changes happen after the mode fixes Site files in that folder end up owned by the FTP user. Use group access for the site's user instead of changing the owner.
777 sets every file to 777; 555 sets every file executable Too wide, and it can't be undone selectively. Use 775/664, and 444 for files, if these modes are needed at all.
755/644 is applied to every file in the default mode Removes executable bits and loosens private files such as a 600 wp-config.php. Keep existing executable bits, or leave files with stricter modes.
A mode other than 777, 755, or 555 is ignored, and fix 755 is read as a domain Easy to type wrong. Print an error and accept the mode in either position.
chmod 775 .../phpmyadmin/config.inc.php The comment says "should not be world writable", but 775 makes the file group-writable and executable. Use 640 or 644.
No lock fix can run at the same time as the runs that create, password, and restores start. Add a lock, or run them one after another.
Domain and mode are placed directly in SQL A quote in a folder name breaks the query. Validate names against ^[a-z0-9.-]+$.
Every folder in /home is processed, and OS is read but never used Extra work, and dead code. Handle only folders that are in the Site table, and remove OS.

See also

Command Description
session Create and set permissions on PHP session directories
create Create a GoAdmio account from the command line
password Change a GoAdmio account password from the command line
ftp Create or edit FTP accounts for a domain
permission Enable or disable FTP permissions for a domain
jailedshell Enable or disable a chrooted SSH shell for a domain
snapshot Restic-based per-domain snapshot backup and restore
quota Enable disk quotas in GoAdmio