From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 12/16] Configuration: Introduce $c{Username}
Date: Mon, 7 Dec 2015 17:27:30 +0000 [thread overview]
Message-ID: <1449509254-27007-13-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com>
This makes it easier to share the output of whoami. As a beneficial
side effect it can now be overridden.
Replace many open-coded calls to `whoami` etc. with references to
$c{Username}.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch
---
Osstest.pm | 5 +++--
Osstest/Executive.pm | 15 ++++-----------
README | 4 ++++
mg-crontab-install | 2 +-
mg-execute-flight | 2 +-
mg-schema-test-database | 4 ++--
6 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/Osstest.pm b/Osstest.pm
index 20b8f62..d4ddda7 100644
--- a/Osstest.pm
+++ b/Osstest.pm
@@ -209,6 +209,7 @@ sub readglobalconfig () {
my $whoami = `whoami` or die $!;
chomp($whoami) or die;
+ $c{Username} ||= $whoami;
my $nodename = `uname -n` or die $!;
chomp($nodename) or die;
@@ -219,7 +220,7 @@ sub readglobalconfig () {
$c{TftpPath} ||= "/tftpboot/";
$c{TftpPxeDir} ||= "pxelinux.cfg/";
$c{TftpPxeTemplates} ||= '%ipaddrhex% 01-%etherhyph%';
- $c{TftpPlayDir} ||= "$whoami/osstest/";
+ $c{TftpPlayDir} ||= "$c{Username}/osstest/";
$c{TftpTmpDir} ||= "$c{TftpPlayDir}tmp/";
$c{TftpDiBase} ||= "$c{TftpPlayDir}debian-installer";
@@ -229,7 +230,7 @@ sub readglobalconfig () {
$c{TftpGrubVersion} ||= 'current';
$c{WebspaceFile} ||= "$ENV{'HOME'}/public_html/";
- $c{WebspaceUrl} ||= "http://$myfqdn/~$whoami/";
+ $c{WebspaceUrl} ||= "http://$myfqdn/~$c{Username}/";
$c{WebspaceCommon} ||= 'osstest/';
$c{WebspaceLog} ||= '/var/log/apache2/access.log';
diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 2214084..fcef83f 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -134,19 +134,14 @@ sub opendb_state () {
return opendb('statedb');
}
-our $whoami;
-
sub db_pg_dsn ($) {
my ($dbname) = @_;
my $pg= $c{"ExecutiveDbname_$dbname"};
if (!defined $pg) {
- if (!defined $whoami) {
- $whoami = `whoami`; die if $?; chomp $whoami;
- }
my $pat= $c{ExecutiveDbnamePat};
my %vars= ('dbname' => $dbname,
- 'whoami' => $whoami);
+ 'whoami' => $c{Username});
$pat =~ s#\<(\w+)\>#
my $val=$vars{$1}; defined $val or die "$pat $1 ?";
$val;
@@ -449,10 +444,9 @@ sub findtask () {
my $q;
my $what;
if (!defined $spec) {
- $!=0; $?=0; my $whoami= `whoami`; defined $whoami or die "$? $!";
$!=0; $?=0; my $node= `uname -n`; defined $node or die "$? $!";
- chomp($whoami); chomp($node); $node =~ s/\..*//;
- my $refkey= "$whoami\@$node";
+ chomp($node); $node =~ s/\..*//;
+ my $refkey= "$c{Username}\@$node";
$what= "static $refkey";
$q= $dbh_tests->prepare(<<END);
SELECT * FROM tasks
@@ -489,9 +483,8 @@ END
}
sub manual_allocation_base_jobinfo () {
- my $whoami = `whoami`; chomp $whoami;
my $hostname = `uname -n`; chomp $hostname;
- my $info = "$whoami\@$hostname";
+ my $info = "$c{Username}\@$hostname";
my $tty = `tty 2>/dev/null`; chomp $tty;
$info .= " ($tty)" unless $?;
return $info;
diff --git a/README b/README
index 3e64a13..5740ac0 100644
--- a/README
+++ b/README
@@ -535,6 +535,10 @@ TftpPxeTemplatesReal
Timezone
Olson TZ name, used by host and guest installers
+Username
+ User name on this host. Defaults to the output of `whoami'.
+ Should not normally be changed.
+
========================================
Host-specific config settigs
diff --git a/mg-crontab-install b/mg-crontab-install
index 5a59d45..4df8e6e 100755
--- a/mg-crontab-install
+++ b/mg-crontab-install
@@ -12,7 +12,7 @@ case "$#.$1" in
esac
expect="#@@ "
-expect+="`whoami`"
+expect+="`whoami`" # not $c{Username}
expect+="@"
expect+="`hostname -f`"
diff --git a/mg-execute-flight b/mg-execute-flight
index 8b2c21c..ec534da 100755
--- a/mg-execute-flight
+++ b/mg-execute-flight
@@ -53,7 +53,7 @@ done
if [ x"$flight" = x ]; then badusage; fi
: ${blessing:=play}
-: ${email:=`whoami`}
+: ${email:=`getconfig Username`}
set +e
tty=`exec 2>/dev/null; tty`
diff --git a/mg-schema-test-database b/mg-schema-test-database
index 73d92f3..b1b5e60 100755
--- a/mg-schema-test-database
+++ b/mg-schema-test-database
@@ -174,7 +174,7 @@ borrowtaskid () {
"
}
-username=`whoami`
+username=`getconfig Username`
nodename=`uname -n`
suffix=_$username
invocation_now=`date +%s`
@@ -223,7 +223,7 @@ create)
moretasks error \
"WHERE type = 'static'
AND refkey = :'refkey'" \
- -v refkey="$(whoami)@$(uname -n)"
+ -v refkey="${username}@$(uname -n)"
fi
tasks_cond=${tasks// / OR T=}
--
1.7.10.4
next prev parent reply other threads:[~2015-12-07 17:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 17:27 (no subject) Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 01/16] tcl daemons: log host and port number we bind to, at startup Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 02/16] cri-getconfig: Break out exec_resetting_sigint Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 03/16] Configuration: No longer set password=<~/.xen-osstest/db-password> Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 04/16] mg-debug-fail: New utility script for debugging Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 05/16] mg-debug-fail: Catch attempts to read from a tty Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 06/16] cri-getconfig: Provide get_psql_cmd and get_pgdump_cmd Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 07/16] cri-getconfig: Provide debugging for get_psql_cmd Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 08/16] Osstest.pm: Break out and export globalconfigfiles Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 09/16] mg-schema-test-database: New script Ian Jackson
2015-12-08 11:06 ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 10/16] mg-schema-test-database: Move setting of test_cfg_setting to dbname Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 11/16] mg-schema-test-database: Sort out daemons; provide `daemons' subcommand Ian Jackson
2015-12-08 11:06 ` Ian Campbell
2015-12-07 17:27 ` Ian Jackson [this message]
2015-12-08 11:07 ` [OSSTEST PATCH 12/16] Configuration: Introduce $c{Username} Ian Campbell
2015-12-08 11:18 ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 13/16] mg-schema-test-database: Change username for back-to-main-db xref Ian Jackson
2015-12-08 11:09 ` Ian Campbell
2015-12-08 14:21 ` Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 14/16] mg-schema-test-database: Bump flight sequence number in test DB Ian Jackson
2015-12-08 11:10 ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 15/16] mg-schema-test-database: Safety catch in JobDB database open Ian Jackson
2015-12-08 11:16 ` Ian Campbell
2015-12-08 14:24 ` Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 16/16] mg-schema-test-database: Add workflow doc comment Ian Jackson
2015-12-08 11:19 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449509254-27007-13-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).