X7ROOT File Manager
Current Path:
/usr/local/cpanel/scripts
usr
/
local
/
cpanel
/
scripts
/
๐
..
๐
MirrorSearch_pingtest
(2.38 KB)
๐
activesync-invite-reply
(1.69 KB)
๐
add_dns
(2.36 KB)
๐
adddns
(2.36 KB)
๐
addpop
(6.08 KB)
๐
addsystemuser
(3.27 KB)
๐
adduser
(92 B)
๐
apachelimits
(4.31 KB)
๐
archive_sync_zones
(3.02 KB)
๐
auto-adjust-mysql-limits
(1.81 KB)
๐
autorepair
(1.24 KB)
๐
backups_clean_metadata_for_missing_backups
(1.57 KB)
๐
backups_create_metadata
(15.75 KB)
๐
backups_list_user_files
(4.56 KB)
๐
balance_linked_node_quotas
(2.58 KB)
๐
biglogcheck
(1.69 KB)
๐
build_bandwidthdb_root_cache_in_background
(1.52 KB)
๐
build_cpnat
(3.41 KB)
๐
build_mail_sni
(3.87 KB)
๐
build_maxemails_config
(1.14 KB)
๐
builddovecotconf
(6.76 KB)
๐
buildeximconf
(7 KB)
๐
buildhttpdconf
(2.6 KB)
๐
buildnsdconf
(1.01 KB)
๐
buildpureftproot
(539 B)
๐
ccs-check
(4.91 KB)
๐
check_cpanel_pkgs
(10.75 KB)
๐
check_cpanel_rpms
(218 B)
๐
check_domain_tls_service_domains.pl
(6.68 KB)
๐
check_immutable_files
(5.49 KB)
๐
check_mail_spamassassin_compiledregexps_body_0
(187 B)
๐
check_maxmem_against_domains_count
(3.57 KB)
๐
check_mount_procfs
(2.02 KB)
๐
check_mysql
(5.55 KB)
๐
check_security_advice_changes
(8.28 KB)
๐
check_unmonitored_enabled_services
(4.56 KB)
๐
check_unreliable_resolvers
(3.59 KB)
๐
check_users_my_cnf
(6.05 KB)
๐
check_valid_server_hostname
(7.66 KB)
๐
checkalldomainsmxs
(2.4 KB)
๐
checkbashshell
(1.18 KB)
๐
checkccompiler
(1.22 KB)
๐
checkexim.pl
(3.1 KB)
๐
checklink
(1.29 KB)
๐
checknsddirs
(1014 B)
๐
checkusers
(856 B)
๐
chkmydns
(561 B)
๐
chkpaths
(141 B)
๐
chpass
(416 B)
๐
ckillall
(1.11 KB)
๐
clean_dead_mailman_locks
(2.09 KB)
๐
clean_up_temp_wheel_users
(2.44 KB)
๐
clean_user_php_sessions
(4.76 KB)
๐
cleandns
(13.09 KB)
๐
cleandns8
(417 B)
๐
cleanmsglog
(735 B)
๐
cleanphpsessions
(932 B)
๐
cleanphpsessions.php
(658 B)
๐
cleanquotas
(1.61 KB)
๐
cleansessions
(5.91 KB)
๐
cleanupinterchange
(2.64 KB)
๐
cleanupmysqlprivs
(533 B)
๐
clear_cpaddon_ui_caches
(1.27 KB)
๐
clear_orphaned_virtfs_mounts
(3.56 KB)
๐
comparecdb
(1.52 KB)
๐
compilers
(2.86 KB)
๐
compilerscheck
(999 B)
๐
configure_firewall_for_cpanel
(520 B)
๐
configure_rh_firewall_for_cpanel
(520 B)
๐
configure_rh_ipv6_firewall_for_cpanel
(520 B)
๐
convert2dovecot
(682 B)
๐
convert_accesshash_to_token
(4.07 KB)
๐
convert_and_migrate_from_legacy_backup
(1.97 KB)
๐
convert_maildir_to_mdbox
(1.66 KB)
๐
convert_mdbox_to_maildir
(1.66 KB)
๐
convert_roundcube_mysql2sqlite
(25.28 KB)
๐
convert_to_dovecot_delivery
(4.33 KB)
๐
convert_whmxfer_to_sqlite
(1.46 KB)
๐
copy_user_mail_as_root
(1.25 KB)
๐
copy_user_mail_as_user
(1.34 KB)
๐
cpaddonsup
(3.25 KB)
๐
cpan_config
(2.8 KB)
๐
cpan_sandbox
๐
cpanel_initial_install
(67.36 KB)
๐
cpanelsync
(28.31 KB)
๐
cpanelsync_postprocessor
(1.62 KB)
๐
cpanpingtest
(965 B)
๐
cpbackup
(44.77 KB)
๐
cpbackup_transport_file
(5.65 KB)
๐
cpdig
(1.81 KB)
๐
cpfetch
(1.23 KB)
๐
cphulkdblacklist
(433 B)
๐
cphulkdwhitelist
(1.3 KB)
๐
cpservice
(2.87 KB)
๐
cpuser_port_authority
(19.29 KB)
๐
cpuser_service_manager
(10.85 KB)
๐
createacct
(24.57 MB)
๐
custom_backup_destination.pl.sample
(5.06 KB)
๐
custom_backup_destination.pl.skeleton
(2.84 KB)
๐
dav_change_hostname
(3.57 KB)
๐
dcpumon-wrapper
(850 B)
๐
delpop
(6.2 KB)
๐
detect_env_capabilities
(508 B)
๐
disable_prelink
(2.77 KB)
๐
disable_sqloptimizer
(1.49 KB)
๐
disablefileprotect
(2.09 KB)
๐
distro_changed_hook
(1.16 KB)
๐
dnscluster
(4.44 KB)
๐
dnsqueuecron
(1.29 KB)
๐
dnssec-cluster-keys
(3.75 KB)
๐
dovecot_maintenance
(7.93 KB)
๐
dovecot_set_defaults.pl
(984 B)
๐
dumpcdb
(866 B)
๐
dumpinodes
(687 B)
๐
dumpquotas
(616 B)
๐
dumpstor
(913 B)
๐
ea4_fresh_install
(2.64 KB)
๐
edit_cpanelsync_exclude_list
(2.58 KB)
๐
editquota
(3.44 KB)
๐
elevate-cpanel
(377.87 KB)
๐
email_archive_maintenance
(6.15 KB)
๐
email_hold_maintenance
(1.46 KB)
๐
enable_spf_dkim_globally
(8.83 KB)
๐
enable_sqloptimizer
(1.57 KB)
๐
enablefileprotect
(2.1 KB)
๐
ensure_autoenabled_features
(2.5 MB)
๐
ensure_conf_dir_crt_key
(4.82 KB)
๐
ensure_cpuser_file_ip
(2.55 KB)
๐
ensure_crontab_permissions
(1.08 KB)
๐
ensure_dovecot_memory_limits_meet_minimum
(3.13 KB)
๐
ensure_hostname_resolves
(2.57 KB)
๐
ensure_includes
(601 B)
๐
ensure_vhost_includes
(13.53 KB)
๐
exim_tidydb
(2.96 KB)
๐
eximconfgen
(1.32 KB)
๐
eximstats_spam_check
(867 B)
๐
export_horde_calendars_to_ics
(15.07 KB)
๐
export_horde_contacts_to_vcf
(13.94 KB)
๐
exportmydnsdb
(3.47 KB)
๐
expunge_expired_certificates_from_sslstorage
(3.56 KB)
๐
expunge_expired_pkgacct_sessions
(852 B)
๐
expunge_expired_transfer_sessions
(1.06 KB)
๐
fastmail
(5.16 KB)
๐
featuremod
(1.92 KB)
๐
fetchfile
(422 B)
๐
find_and_fix_rpm_issues
(6.99 KB)
๐
find_outdated_services
(5.41 KB)
๐
find_pids_with_inotify_watch_on_path
(3.66 KB)
๐
fix-cpanel-perl
(28.82 KB)
๐
fix-listen-on-localhost
(3.52 KB)
๐
fix-web-vhost-configuration
(6.15 KB)
๐
fix_addon_permissions
(7.68 KB)
๐
fix_dns_zone_ttls
(1.34 KB)
๐
fix_innodb_tables
(4.05 KB)
๐
fix_pear_registry
(4.07 KB)
๐
fix_reseller_acls
(10.88 KB)
๐
fixetchosts
(4.32 KB)
๐
fixheaders
(572 B)
๐
fixmailinglistperms
(1008 B)
๐
fixmailman
(2.09 KB)
๐
fixnamedviews
(1.22 KB)
๐
fixndc
(413 B)
๐
fixquotas
(17.45 KB)
๐
fixrelayd
(1.74 KB)
๐
fixrndc
(16.48 KB)
๐
fixtar
(503 B)
๐
fixtlsversions
(4.7 KB)
๐
fixvaliases
(2 KB)
๐
fixwebalizer
(966 B)
๐
forcelocaldomain
(895 B)
๐
ftpfetch
(2.2 KB)
๐
ftpquotacheck
(8.31 KB)
๐
ftpsfetch
(2.36 KB)
๐
ftpupdate
(261 B)
๐
gather_update_log_stats
(4.25 KB)
๐
gather_update_logs_setupcrontab
(5.45 KB)
๐
gemwrapper
(1.74 KB)
๐
gencrt
(6.26 KB)
๐
generate_account_suspension_include
(5.7 KB)
๐
generate_google_drive_credentials
(1.11 KB)
๐
generate_google_drive_oauth_uri
(984 B)
๐
generate_maildirsize
(13.94 KB)
๐
gensysinfo
(1.16 KB)
๐
get_locale_from_legacy_name_info
(1.99 KB)
๐
getremotecpmove
(12.67 KB)
๐
grpck
(1.19 KB)
๐
hackcheck
(3.02 KB)
๐
hook
(1.45 KB)
๐
httpspamdetect
(2.66 KB)
๐
hulk-unban-ip
(3.93 MB)
๐
import_exim_data
(8.39 KB)
๐
importmydnsdb
(11.34 KB)
๐
increase_filesystem_limits
(891 B)
๐
initacls
(4.99 KB)
๐
initfpsuexec
(444 B)
๐
initquotas
(19.47 KB)
๐
initsuexec
(4.03 KB)
๐
install_cpanel_analytics
(1.93 KB)
๐
install_dovecot_fts
(1.57 KB)
๐
install_plugin
(2.8 KB)
๐
installpkg
(575 B)
๐
installpostgres
(6.56 KB)
๐
installsqlite3
(1.82 KB)
๐
ipcheck
(3.93 KB)
๐
ipusage
(7.45 KB)
๐
isdedicatedip
(602 B)
๐
jetbackup-check
(3.69 KB)
๐
killdns
(422 B)
๐
killdns-dnsadmin
(1.15 KB)
๐
killmysqluserprivs
(433 B)
๐
killmysqlwildcard
(1.15 KB)
๐
killpvhost
(853 B)
๐
killspamkeys
(937 B)
๐
link_3rdparty_binaries
(1.24 KB)
๐
linksubemailtomainacct
(3.17 KB)
๐
listcheck
(538 B)
๐
listsubdomains
(1.05 KB)
๐
litespeed-check
(3.86 KB)
๐
locale_export
(4.82 KB)
๐
locale_import
(4.35 KB)
๐
locale_info
(3.99 KB)
๐
logo.dat
(205 B)
๐
magicloader
(1.94 KB)
๐
maildir_converter
(6.08 KB)
๐
mailperm
(16.58 KB)
๐
mailscannerupdate
(2.42 KB)
๐
mainipcheck
(10 KB)
๐
maintenance
(46.62 KB)
๐
make_config
(407 B)
๐
make_hostname_unowned
(1.16 KB)
๐
manage_extra_marketing
(12.41 KB)
๐
manage_greylisting
(16.19 KB)
๐
manage_mysql_profiles
(20.02 KB)
๐
migrate-pdns-conf
(9.83 KB)
๐
migrate_local_ini_to_php_ini
(7.41 KB)
๐
migrate_whmtheme_file_to_userdata
(2.95 KB)
๐
mkwwwacctconf
(2.33 KB)
๐
modify_accounts
(4.09 KB)
๐
modify_featurelist
(9.2 KB)
๐
modify_packages
(3.65 KB)
๐
modsec_vendor
(15.63 KB)
๐
mysqlconnectioncheck
(6.55 KB)
๐
mysqlpasswd
(4.09 KB)
๐
named.ca
(1.57 KB)
๐
named.rfc1912.zones
(774 B)
๐
nixstatsagent.sh
(58.67 KB)
๐
notify_expiring_certificates
(9.37 KB)
๐
notify_expiring_certificates_on_linked_nodes
(1.33 KB)
๐
oopscheck
(1.12 KB)
๐
optimize_eximstats
(3.88 KB)
๐
patch_mail_spamassassin_compiledregexps_body_0
(2.39 KB)
๐
patchfdsetsize
(2.72 KB)
๐
pedquota
(2.26 KB)
๐
perform_sqlite_auto_rebuild_db_maintenance
(2.2 KB)
๐
perlinstaller
(528 B)
๐
perlmods
(1.18 KB)
๐
php_fpm_config
(9.73 KB)
๐
php_sandbox
๐
phpini_tidy
(687 B)
๐
pkgacct
(87.82 KB)
๐
post_snapshot
(3.16 KB)
๐
post_sync_cleanup
(6.09 KB)
๐
primary_virtual_host_migration
(2.44 KB)
๐
process_pending_cpanel_php_pear_registration
(3.49 KB)
๐
process_site_templates
(7.27 KB)
๐
proxydomains
(9.34 KB)
๐
ptycheck
(724 B)
๐
purge_modsec_log
(1.53 KB)
๐
purge_old_config_caches
(2.08 KB)
๐
pwck
(708 B)
๐
quickdnslookup
(1.13 KB)
๐
quickwhoisips
(2.29 KB)
๐
quota_auto_fix
(1.41 KB)
๐
quotacheck
(22.36 KB)
๐
rawchpass
(460 B)
๐
rdate
(4.8 KB)
๐
realadduser
(5.61 KB)
๐
realchpass
(3.26 KB)
๐
realperlinstaller
(5.67 KB)
๐
realrawchpass
(425 B)
๐
rebuild_available_addons_packages_cache
(1.27 KB)
๐
rebuild_available_rpm_addons_cache
(1.27 KB)
๐
rebuild_bandwidthdb_root_cache
(1.45 KB)
๐
rebuild_dbmap
(5.8 KB)
๐
rebuild_provider_openid_connect_links_db
(1.01 KB)
๐
rebuild_whm_chrome
(2.22 KB)
๐
rebuilddnsconfig
(26.21 KB)
๐
rebuildhttpdconf
(2.6 KB)
๐
rebuildinstalledssldb
(2.85 KB)
๐
rebuildippool
(509 B)
๐
rebuildnsdzones
(1.14 KB)
๐
rebuilduserssldb
(948 B)
๐
refresh-dkim-validity-cache
(5.97 KB)
๐
regenerate_tokens
(2.18 KB)
๐
reloadnsd
(821 B)
๐
remote_log_transfer
(11.6 KB)
๐
remove_dovecot_index_files
(5.89 KB)
๐
removeacct
(20.91 MB)
๐
rescan_user_dovecot_fts
(2.98 KB)
๐
reset_mail_quotas_to_sane_values
(6.82 KB)
๐
resetmailmanurls
(2.03 KB)
๐
resetquotas
(4.68 KB)
๐
restartsrv
(3.23 KB)
๐
restartsrv_apache
(422 B)
๐
restartsrv_apache_php_fpm
(9.9 MB)
๐
restartsrv_base
(9.9 MB)
๐
restartsrv_bind
(9.9 MB)
๐
restartsrv_chkservd
(427 B)
๐
restartsrv_clamd
(9.9 MB)
๐
restartsrv_cpanalyticsd
(9.9 MB)
๐
restartsrv_cpanel_php_fpm
(9.9 MB)
๐
restartsrv_cpanellogd
(9.9 MB)
๐
restartsrv_cpdavd
(9.9 MB)
๐
restartsrv_cpgreylistd
(9.9 MB)
๐
restartsrv_cphulkd
(9.9 MB)
๐
restartsrv_cpipv6
(9.9 MB)
๐
restartsrv_cpsrvd
(9.9 MB)
๐
restartsrv_crond
(9.9 MB)
๐
restartsrv_dnsadmin
(9.9 MB)
๐
restartsrv_dovecot
(9.9 MB)
๐
restartsrv_exim
(9.9 MB)
๐
restartsrv_eximstats
(504 B)
๐
restartsrv_ftpd
(426 B)
๐
restartsrv_ftpserver
(911 B)
๐
restartsrv_httpd
(9.9 MB)
๐
restartsrv_imap
(437 B)
๐
restartsrv_inetd
(2.47 KB)
๐
restartsrv_ipaliases
(9.9 MB)
๐
restartsrv_lmtp
(437 B)
๐
restartsrv_mailman
(9.9 MB)
๐
restartsrv_mydns
(9.9 MB)
๐
restartsrv_mysql
(9.9 MB)
๐
restartsrv_named
(777 B)
๐
restartsrv_nscd
(9.9 MB)
๐
restartsrv_nsd
(9.9 MB)
๐
restartsrv_p0f
(9.9 MB)
๐
restartsrv_pdns
(9.9 MB)
๐
restartsrv_pop3
(437 B)
๐
restartsrv_postgres
(427 B)
๐
restartsrv_postgresql
(9.9 MB)
๐
restartsrv_powerdns
(442 B)
๐
restartsrv_proftpd
(9.9 MB)
๐
restartsrv_pureftpd
(9.9 MB)
๐
restartsrv_queueprocd
(9.9 MB)
๐
restartsrv_rsyslog
(9.9 MB)
๐
restartsrv_rsyslogd
(437 B)
๐
restartsrv_spamd
(9.9 MB)
๐
restartsrv_sshd
(9.9 MB)
๐
restartsrv_syslogd
(2.4 KB)
๐
restartsrv_tailwatchd
(9.9 MB)
๐
restartsrv_unknown
(9.9 MB)
๐
restartsrv_xinetd
(422 B)
๐
restorecpuserfromcache
(1.96 KB)
๐
restorepkg
(36.49 MB)
๐
rfc1912_zones.tar
(10 KB)
๐
rpmup
(4.77 KB)
๐
rsync-user-homedir.pl
(5.76 KB)
๐
run_if_exists
(512 B)
๐
run_plugin_lifecycle
(3.53 KB)
๐
runstatsonce
(440 B)
๐
runweblogs
(1.02 KB)
๐
sa-update_wrapper
(3.34 KB)
๐
safetybits.pl
(844 B)
๐
secureit
(4.72 KB)
๐
securemysql
(4.54 KB)
๐
securerailsapps
(3.58 KB)
๐
securetmp
(15.99 KB)
๐
sendicq
(474 B)
๐
servicedomains
(9.34 KB)
๐
set_mailman_archive_perms
(1.75 KB)
๐
set_php_memory_limits
(3.67 KB)
๐
setpostgresconfig
(6.04 KB)
๐
setup_greylist_db
(16.19 KB)
๐
setup_modsec_db
(1.3 KB)
๐
setup_systemd_timer_for_plugins
(3.92 KB)
๐
setupftpserver
(10.47 KB)
๐
setupmailserver
(9.55 KB)
๐
setupnameserver
(13.75 KB)
๐
shrink_modsec_ip_database
(12.97 KB)
๐
simpleps
(3.05 KB)
๐
slurp_exim_mainlog
(5.78 KB)
๐
smartcheck
(15.13 KB)
๐
smtpmailgidonly
(8.15 KB)
๐
snapshot_prep
(5.88 KB)
๐
spamassassin_dbm_cleaner
(5.85 KB)
๐
spamassassindisable
(3.74 KB)
๐
spamboxdisable
(2.27 KB)
๐
sshcontrol
(14.38 KB)
๐
ssl_crt_status
(3.84 KB)
๐
suspendacct
(18.01 KB)
๐
suspendmysqlusers
(4.42 KB)
๐
swapip
(3.82 KB)
๐
sync-mysql-users-from-grants
(1.2 KB)
๐
sync_child_accounts
(1.77 KB)
๐
sync_contact_emails_to_cpanel_users_files
(1.14 KB)
๐
synccpaddonswithsqlhost
(6.59 KB)
๐
synctransfers
(1.92 KB)
๐
syslog_check
(1.36 KB)
๐
sysup
(645 B)
๐
test_sa_compiled
(1.07 KB)
๐
transfer_account_as_user
(2.34 KB)
๐
transfer_accounts_as_root
(4.76 KB)
๐
transfer_in_progress
(3.08 KB)
๐
transfer_in_progress.pod
(312 B)
๐
transfermysqlusers
(9.53 MB)
๐
try-later
(7.95 KB)
๐
unblockip
(667 B)
๐
uninstall_cpanel_analytics
(1.2 KB)
๐
uninstall_dovecot_fts
(562 B)
๐
uninstall_plugin
(2.84 KB)
๐
unlink_service_account
(2.62 KB)
๐
unpkgacct
(4.6 KB)
๐
unslavenamedconf
(863 B)
๐
unsuspendacct
(17.8 KB)
๐
unsuspendmysqlusers
(6.71 KB)
๐
upcp
(31.56 KB)
๐
upcp-running
(2.7 KB)
๐
upcp.static
(708.6 KB)
๐
update-packages
(4.77 KB)
๐
update_apachectl
(480 B)
๐
update_db_cache
(430 B)
๐
update_dkim_keys
(1.45 KB)
๐
update_exim_rejects
(1.21 KB)
๐
update_existing_mail_quotas_for_account
(4.78 KB)
๐
update_known_proxy_ips
(1002 B)
๐
update_local_rpm_versions
(4.56 KB)
๐
update_mailman_cache
(8.34 KB)
๐
update_mysql_systemd_config
(1.25 KB)
๐
update_neighbor_netblocks
(487 B)
๐
update_sa_config
(2.14 KB)
๐
update_spamassassin_config
(10.73 KB)
๐
update_users_jail
(691 B)
๐
update_users_vhosts
(801 B)
๐
updatedomainips
(605 B)
๐
updatenameserverips
(1.66 KB)
๐
updatenow
(5.18 KB)
๐
updatenow.static
(1.91 MB)
๐
updatesigningkey
(1.95 KB)
๐
updatessldomains
(1.81 KB)
๐
updatesupportauthorizations
(2.49 KB)
๐
updateuserdatacache
(2.47 KB)
๐
updateuserdomains
(774 B)
๐
upgrade_bandwidth_dbs
(2.22 KB)
๐
upgrade_subaccount_databases
(2.73 KB)
๐
userdata_wildcard_cleanup
(5.74 KB)
๐
userdirctl
(5.01 KB)
๐
validate_sshkey_passphrase
(1.21 KB)
๐
verify_api_spec_files
(757 B)
๐
verify_pidfile
(1.96 KB)
๐
verify_vhost_includes
(7.34 KB)
๐
vps_optimizer
(7.82 KB)
๐
vzzo-fixer
(725 B)
๐
whmlogin
(2.33 KB)
๐
whoowns
(1.13 KB)
๐
wpt_license
(6.27 MB)
๐
wwwacct
(24.57 MB)
๐
wwwacct2
(88 B)
๐
xfer_rcube_schema_migrate.pl
(2.4 KB)
๐
xfer_rcube_uid_resolver.pl
(1.8 KB)
๐
xferpoint
(3.13 KB)
๐
xfertool
(16.14 KB)
๐
zoneexists
(800 B)
Editing: check_valid_server_hostname
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/check_valid_server_hostname Copyright 2022 cPanel, L.L.C. # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited # package scripts::check_valid_server_hostname; use strict; use warnings; use Cpanel::Locale (); use Cpanel::Usage (); use Cpanel::Config::LoadWwwAcctConf (); use Cpanel::Sys::Hostname (); use Cpanel::Redirect (); use Cpanel::DIp::MainIP (); use Socket (); my $HOSTNAME_OK = 0; my $GENERIC_HOSTNAME_ERROR = 1; my $NEEDS_SET_HOSTNAME = 2; sub script { my $self = shift; my $argv = shift; my $lc = Cpanel::Locale->get_handle(); my %opts = ( notify => 0, quiet => 0, ); Cpanel::Usage::wrap_options( $argv, \&usage, { 'notify' => \$opts{'notify'}, 'quiet' => \$opts{'quiet'} }, ); my $hostname = Cpanel::Sys::Hostname::gethostname(); if ( my $is_manual_hostname = $self->is_manual_hostname( $hostname, \%opts ) ) { if ( $is_manual_hostname == $NEEDS_SET_HOSTNAME ) { require Whostmgr::Hostname; my ( $status, $statusmsg, $msgref, $errref ) = Whostmgr::Hostname::sethostname( $hostname, 1 ); unless ( $opts{'quiet'} ) { if ( $msgref && ref $msgref ) { print "$_\n" for @$msgref; } if ( !$status ) { warn $statusmsg; if ( $errref && ref $errref ) { warn "$_" for @$errref; } } } exit 1 if !$status; } else { exit 1; } } exit 1 unless $self->is_resolv_hostname( $hostname, \%opts ); print $lc->maketext(q{OK}), "\n" unless $opts{'quiet'}; exit 0; } sub usage { my $lc = Cpanel::Locale->get_handle(); print $lc->maketext(q{This tool verifies the server hostname configuration.}), "\n\n"; print $lc->maketext( q{Usage: [_1][comment,a program name] ~[options~]}, $0 ), "\n\n"; print $lc->maketext(q{Options:}), "\n"; print "\t--help ", $lc->maketext(q{Display this help message.}), "\n"; print "\t--notify ", $lc->maketext(q{Send a failure notification to the system administrator.}), "\n"; print "\t--quiet ", $lc->maketext(q{Do not display output, and instead set the [output,asis,UNIX] exit code.}), "\n\n"; exit 0; } # Do not use Cpanel::Hostname::gethostname(). The purpose of this routine # is to reliably detect from the definitive source on Linux, what it thinks # it's running as. That is then compared to the WHM setting. sub is_manual_hostname { my $self = shift; my $hostname = shift; my $opts = shift; my $conf = Cpanel::Config::LoadWwwAcctConf::loadwwwacctconf(); my $lc = Cpanel::Locale->get_handle(); my $old = $lc->set_context_plain(); my $ip = Cpanel::DIp::MainIP::getmainip(); unless ($conf) { my $reason = $lc->maketext(q{The system is unable to retrieve the [output,asis,WHM] hostname configuration information.}); my $solution = $lc->maketext( q{Verify the file system permissions of the โ[_1]โ file on your server.}, q{/etc/wwwacct.conf} ); $self->send_failure_notification( $opts, { 'status' => 'cannot_read_conf', 'reason' => $reason, 'solution' => $solution, 'hostname' => $hostname, 'ip' => $ip } ); $lc->set_context($old); return $GENERIC_HOSTNAME_ERROR; } my $url = sprintf( 'http://%s:2087/scripts2/changehostname', Cpanel::Redirect::getserviceSSLdomain('whm') ); my $solution = $lc->maketext( q{The system will attempt to synchronize the current hostname โ[_1]โ to the system configuration.}, $hostname ) . ' ' . $lc->maketext( q{In the future, update your hostname in [output,url,_1,WHMโs] interface (Home ยป Networking Setup ยป Change Hostname).}, $url ); unless ( $conf->{'HOST'} ) { my $reason = $lc->maketext(q{The system hostname is not configured in [output,asis,WHM].}); $self->send_failure_notification( $opts, { 'status' => 'host_missing', 'reason' => $reason, 'solution' => $solution, 'hostname' => $hostname, 'ip' => $ip } ); $lc->set_context($old); return $NEEDS_SET_HOSTNAME; } unless ( $hostname eq $conf->{'HOST'} ) { my $reason = $lc->maketext(q{[output,asis,WHM] has detected a manual hostname change.}); $self->send_failure_notification( $opts, { 'status' => 'hostname_host_mismatch', 'reason' => $reason, 'solution' => $solution, 'hostname' => $hostname, 'ip' => $ip } ); $lc->set_context($old); return $NEEDS_SET_HOSTNAME; } $lc->set_context($old); return $HOSTNAME_OK; } # This uses gethostbyname(), because Apache does. If Apache is unable to resolve the # hostname on the machine using the standard default EasyApache profile, then it won't # start (due to mod_unique_id). sub is_resolv_hostname { my $self = shift; my $hostname = shift; my $opts = shift; my $lc = Cpanel::Locale->get_handle(); my $old = $lc->set_context_plain(); my $solution = $lc->maketext( q{Update your system โ[_1]โ file and/or [output,asis,DNS] server.}, q{/etc/hosts} ); my $ip = Cpanel::DIp::MainIP::getmainip(); my $resolved = gethostbyname($hostname); unless ($resolved) { my $reason = $lc->maketext( q{The system was unable to resolve the system hostname โ[_1]โ to an [output,asis,IP] address.}, $hostname ); $self->send_failure_notification( $opts, { 'status' => 'cannot_resolve_hostname', 'reason' => $reason, 'solution' => $solution, 'hostname' => $hostname, 'ip' => $ip } ); $lc->set_context($old); return 0; } $lc->set_context($old); return 1; } sub send_failure_notification { my $self = shift; my $opts = shift; my $args = shift; my $lc = Cpanel::Locale->get_handle(); my $old = $lc->set_context_plain(); print STDERR $lc->maketext('ERROR:'), " $args->{'reason'}\n" unless $opts->{'quiet'}; print STDERR "\n$args->{'solution'}\n" if $args->{'solution'}; unless ( $opts->{'notify'} ) { $lc->set_context($old); return 1; } require Cpanel::Notify; Cpanel::Notify::notification_class( 'class' => 'Check::ValidServerHostname', 'application' => 'server_hostname_validator', 'status' => $args->{'status'}, 'interval' => 86400 * 7, 'constructor_args' => [ 'origin' => 'server_hostname_validator', 'reason' => $args->{'reason'}, 'solution' => $args->{'solution'}, 'ip' => $args->{'ip'}, ] ); $lc->set_context($old); return 1; } __PACKAGE__->script( \@ARGV ) unless caller; __END__ =head1 NAME check_valid_server_hostname - Verifies proper configuration of hostname =head1 DESCRIPTION This script checks the hostname of the machine and verifies that the user has properly configured it in cPanel & WHM. Additionally, it performs a DNS check on the hostname. Both of these verifications, in tandem, help to ensure the user has a properly configured and functioning server.
Upload File
Create Folder