Defined constants to include in other scripts + absolute include

This commit is contained in:
xdrm-brackets 2017-01-27 11:09:34 +01:00
parent f346057793
commit 30db779020
4 changed files with 16 additions and 13 deletions

View File

@ -1,9 +1,8 @@
#!/usr/bin/php #!/usr/bin/php
<?php
#define('SECRET_FILE', '/home/sats/satsd/conf/machine.secret'); <?php
define('SECRET_FILE', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats/lib/cyclic-hash/secret');
define('SECRET_SIZE', 250); require_once __DIR__.'/../include/const';
/* [1] Function that generates a random secret /* [1] Function that generates a random secret
@ -29,7 +28,7 @@
/* [2] Fetch necessary data /* [2] Fetch necessary data
=========================================================*/ =========================================================*/
/* (1) Fetch secret file */ /* (1) Fetch secret file */
$secret = @file_get_contents(SECRET_FILE); $secret = @file_get_contents(SECRET_CONF);
/* (2) Check secret file format */ /* (2) Check secret file format */
if( !is_string($secret) || !preg_match("/^(.{250}):(\d+)$/", $secret, $match) ){ if( !is_string($secret) || !preg_match("/^(.{250}):(\d+)$/", $secret, $match) ){
@ -38,7 +37,7 @@
$secret = generate_secret().':1000'; $secret = generate_secret().':1000';
// Try to override the secret file // Try to override the secret file
@file_put_contents(SECRET_FILE, $secret) && die(0) || die(127); @file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
} }
/* (3) Extract data */ /* (3) Extract data */
@ -54,7 +53,7 @@
$depth--; $depth--;
/* (2) Try to override the secret file */ /* (2) Try to override the secret file */
@file_put_contents(SECRET_FILE, "$key:$depth") && die(0) || die(127); @file_put_contents(SECRET_CONF, "$key:$depth") && die(0) || die(127);
/* [4] If cannot decrement, generate new password /* [4] If cannot decrement, generate new password
@ -65,7 +64,7 @@
$secret = generate_secret().':1000'; $secret = generate_secret().':1000';
// Try to override the secret file // Try to override the secret file
file_put_contents(SECRET_FILE, $secret) && die(0) || die(127); file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
} }

View File

@ -1,15 +1,14 @@
#!/usr/bin/php #!/usr/bin/php
<?php <?php
#define('SECRET_FILE', '/home/sats/satsd/conf/machine.secret'); require_once __DIR__.'/../include/const';
define('SECRET_FILE', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats/lib/cyclic-hash/secret');
define('SECRET_SIZE', 250);
/* [1] Fetch necessary data /* [1] Fetch necessary data
=========================================================*/ =========================================================*/
/* (1) Fetch secret file */ /* (1) Fetch secret file */
$secret = @file_get_contents(SECRET_FILE); $secret = @file_get_contents(SECRET_CONF);
/* (2) Check secret file format */ /* (2) Check secret file format */
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) ) if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )

1
lib/cyclic-hash/secret Normal file
View File

@ -0,0 +1 @@
2wFkoxlQvF8S3twsVAm705_8HuUCV3dYzTiXpDNUiWLmohOjR9qRfq_XUUyPYMMxE3u3HgXZbIkAZ7TQhjHwJHsCA0ryNc4rgyuXOrW_8fz7nsYELEatkC5VDwspJwR_3kXSMSRU7q1uSZ8CDi5XVbSxIkXrQNqU7mMTeDNl2OPVMYxofCl9OdHvxDWmpmgwI1pWEbhHZ5BL378iKusxH82dLZAakQH2S5ZvgfbflN_oU8HEC8bjgew1c5:992

View File

@ -9,7 +9,8 @@
define('SOURCE_DIR', ROOT_DIR.'/source'); define('SOURCE_DIR', ROOT_DIR.'/source');
# CONFIGURATION FILES # CONFIGURATION FILES
define('SECRET_CONF', CONF_DIR.'/machine.secret'); #define('SECRET_CONF', CONF_DIR.'/machine.secret');
define('SECRET_CONF', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats/lib/cyclic-hash/secret');
define('STATE_CONF', CONF_DIR.'/machine.state'); define('STATE_CONF', CONF_DIR.'/machine.state');
define('BRANCH_CONF', CONF_DIR.'/machine.branch'); define('BRANCH_CONF', CONF_DIR.'/machine.branch');
define('ID_CONF', CONF_DIR.'/machine.id'); define('ID_CONF', CONF_DIR.'/machine.id');
@ -22,4 +23,7 @@
define('DAEMON_LOG', CONF_DIR.'/daemon.log'); define('DAEMON_LOG', CONF_DIR.'/daemon.log');
define('INSTALL_LOG', CONF_DIR.'/install-source.log'); define('INSTALL_LOG', CONF_DIR.'/install-source.log');
define('UPDATE_LOG', CONF_DIR.'/update.log'); define('UPDATE_LOG', CONF_DIR.'/update.log');
# SETTINGS
define('SECRET_SIZE', 250);
?> ?>