From cfe38a1321e755fa246fb18d29ef1bff52c0a094 Mon Sep 17 00:00:00 2001 From: paspo Date: Thu, 15 Sep 2016 00:29:58 +0200 Subject: [PATCH] sudoers fix --- doraemon.spec | 2 +- .../e-smith/templates/etc/sudoers/50doraemon | 17 +++++++++++++---- root/usr/share/doraemon/index.php | 10 ++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/doraemon.spec b/doraemon.spec index bf4793f..5244199 100644 --- a/doraemon.spec +++ b/doraemon.spec @@ -1,7 +1,7 @@ Summary: Helps client to join domain and maintain itself Name: doraemon Version: 2.0.0 -Release: 1.ns6 +Release: 2.ns6 URL: https://github.com/bglug-it/doraemon/ License: GPLv2+ Packager: Paolo Asperti diff --git a/root/etc/e-smith/templates/etc/sudoers/50doraemon b/root/etc/e-smith/templates/etc/sudoers/50doraemon index b456169..06692c8 100644 --- a/root/etc/e-smith/templates/etc/sudoers/50doraemon +++ b/root/etc/e-smith/templates/etc/sudoers/50doraemon @@ -1,6 +1,15 @@ -# -# 50doraemon -# -srvmgr ALL=NOPASSWD: /bin/cat /home/amgmt/.ansible/vault.txt +{ + $OUT = 'srvmgr ALL=NOPASSWD: /bin/cat '; + use esmith::ConfigDB; + my $confdb = esmith::ConfigDB->open; + my $backup = $confdb->get('doraemon') or die "No doraemon db entry found\n"; + my $VaultPassFile = $backup->prop('VaultPassFile') || '/home/amgmt/.ansible/vault.txt'; + my $ManagementKeyFile = $backup->prop('ManagementKeyFile') || '/home/amgmt/.ssh/id_rsa.pub'; + my $DomainFile = $backup->prop('DomainFile') || '/etc/domain.yml'; + $OUT = 'srvmgr ALL=NOPASSWD: /bin/cat ' . $VaultPassFile . ' +srvmgr ALL=NOPASSWD: /bin/cat ' . $ManagementKeyFile .' +srvmgr ALL=NOPASSWD: /bin/cat ' . $DomainFile; + +} diff --git a/root/usr/share/doraemon/index.php b/root/usr/share/doraemon/index.php index b688186..3d61794 100644 --- a/root/usr/share/doraemon/index.php +++ b/root/usr/share/doraemon/index.php @@ -125,19 +125,13 @@ function pingHost($host, $timeout=1) { function ROUTE_domain() { global $config_db; $theFile = $config_db->getProp(CONFIG_KEY,'DomainFile'); - $content = file_get_contents($theFile); - if (false !== $content) { - echo $content; - } + passthru("/usr/bin/sudo /bin/cat $theFile"); } function ROUTE_mgmtkey() { global $config_db; $theFile = $config_db->getProp(CONFIG_KEY,'ManagementKeyFile'); - $content = file_get_contents($theFile); - if (false !== $content) { - echo $content; - } + passthru("/usr/bin/sudo /bin/cat $theFile"); } function ROUTE_epoptes_srv() {