Skip to content

Prevent removal of account when no ip is found

elijah.s@hostdime.com requested to merge master into master

Although very unlikely, if there was an issue obtaining an IP Address for the domain through /scripts/ipusage | grep "$primary_domain" | awk '{print $1}', the script will then mark the IP as dedicated due to $server_ip not matching $ip (because it's empty), and continue on.

It will eventually remove the account and then attempt to restore.

It fails because --ip= is specified with /scripts/restorepkg but is empty:

Beginning the restoration process.
Error: While "strict" is in effect, we have encountered option --ip= on the command line, an option that was not specified in the opts hash.
(XID wn47qj) The parameter “--ip=” is not a known option.

/usr/local/cpanel/bin/restorepkg [--unrestricted] [--restricted] [--force] [--newuser <username>] [--allow_reseller] [--skipaccount] [--ip=(y|n|custom IP)] -- [cpuser|/path/to/cpuser-file|/path/to/extracted-cpuser-file|/path/to/incremental_backup]

 --allow_reseller   Restore reseller privileges if the archive contains them.
                    NOTE: This option is only available in unrestricted mode.

 --force            Force the package to restore and overwrite all account settings
                    and databases.  If the account already exists on the system
                    this implies --skipaccount.

 --ip               Assign a dedicated IP address. You may specify a particular
                    IP address, or “y” to have one randomly assigned.

 --newuser          Specify the username to use for the restored account instead
                    of the one contained within the archive.  Databases and DB
                    users will retain their names unless a conflict is detected.
                    This option cannot be used with --skipaccount.

 --skipaccount      Restore the package into the existing account with the same
                    username. This option cannot be used in conjunction with
                    --newuser.

 --restricted       Use the Restricted Restore feature to restore the package.

 --unrestricted     Restore the package in unrestricted mode. This flag is on by
                    default and overridden by the --restricted flag.


 NOTE: As of cPanel & WHM 11.44, the “--override” option is no longer available.
 Put custom modules in /var/cpanel/perl/Whostmgr/Transfers/Systems/ instead.

 To specify a dedicated IP address for a restored account, the “--ip” option requires an argument of “y” for yes, or “n” for no.
 Alternatively, this option’s value may be a specific IP address to dedicate to the account.

 SECURITY NOTE:
  Do not restore account backups in unrestricted mode from anyone whom you would
  not trust with root access to this server. There are a variety of ways in which
  malicious users may add or escalate privileges via account backups when they
  are restored in unrestricted mode.

  Restricted Restore performs additional security checks on the backup file.
  If a component of the backup file has a security issue, the system will not
  restore that portion of the backup.

  Restricted Restore is experimental and should not be considered an effective security
  control at this time.  It is intended to allow you to restore backups from untrusted
  sources in a future release. cPanel strongly recommends that you do not restore
  data from anyone whom you would not trust with root access to the server.

  For more information, please see: https://go.cpanel.net/insecurerestoreaccount
Restoration complete.

Error: postcheck (backup_restore:768): The 'hdtest' account was not restored properly.

Call stack (most recent call first):
        at postcheck (unknown:147)
        at main (unknown:853)

This was discovered in a dizbox instance (since the IP Addressing isn't quite right: /scripts/ipusage returns one IP while hostname -i returns another, etc).

Edited by elijah.s@hostdime.com

Merge request reports