Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-23-2014, 01:11 PM
|
#1
|
LQ Veteran
Registered: May 2008
Posts: 7,053
|
$HOSTNAME in /etc/profile ?
A quick question to satisfy my curiosity:
Slackware sets $HOSTNAME within /etc/profile. Obviously I know what it is, but does anyone know what it's actually for? Are there any specific programs that reference it?
|
|
|
08-23-2014, 01:18 PM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,776
|
webmin?
|
|
|
08-23-2014, 04:07 PM
|
#3
|
Senior Member
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
|
Quite a few, it seems:
ttk@wip:~> grep -ac HOSTNAME /usr/bin/* /bin/* /usr/local/bin/* /sbin/* /usr/sbin/* /usr/local/sbin/* | & grep -v :0 | grep -v grep:
/usr/bin/bash:2
/usr/bin/ccmake:3
/usr/bin/cmake:3
/usr/bin/cmake-gui:3
/usr/bin/cpack:3
/usr/bin/ctest:3
/usr/bin/curl:1
/usr/bin/distcc:1
/usr/bin/distccd:1
/usr/bin/distccmon-gnome:1
/usr/bin/distccmon-text:1
/usr/bin/epic5:1
/usr/bin/epic5-1.1.6:1
/usr/bin/esdplay:1
/usr/bin/gnome-keyring-daemon:1
/usr/bin/jed:1
/usr/bin/jed-script:1
/usr/bin/jmacs:1
/usr/bin/joe:1
/usr/bin/jpico:1
/usr/bin/jstar:1
/usr/bin/lsdistcc:1
/usr/bin/mysqldumpslow:1
/usr/bin/mysqltest:1
/usr/bin/mysqltest_embedded:1
/usr/bin/net:1
/usr/bin/netwatch:1
/usr/bin/newspost:1
/usr/bin/nn:1
/usr/bin/nnadmin:1
/usr/bin/nnbatch:1
/usr/bin/nncheck:1
/usr/bin/nngoback:1
/usr/bin/nnpost:1
/usr/bin/nntidy:1
/usr/bin/nnview:1
/usr/bin/patch-metamail:4
/usr/bin/perror:1
/usr/bin/rcs2log:1
/usr/bin/rjoe:1
/usr/bin/rn:1
/usr/bin/rtin:1
/usr/bin/slrn:1
/usr/bin/tin:1
/usr/bin/trn:1
/bin/bash:2
/bin/ksh:2
/bin/rksh:2
/bin/sh:2
/sbin/lvmdump:1
/sbin/netconfig:14
/usr/sbin/NetworkManager:2
/usr/sbin/bluetoothd:1
/usr/sbin/dnsmasq:1
/usr/sbin/mtr:1
/usr/sbin/openvpn:1
/usr/sbin/samba_dnsupdate:1
/usr/sbin/samba_spnupdate:1
/usr/sbin/samba_upgradedns:3
/usr/sbin/tcpdump:1
/usr/sbin/tcpdump.4.4.0:1
|
|
|
08-23-2014, 04:35 PM
|
#4
|
LQ Veteran
Registered: May 2008
Posts: 7,053
Original Poster
|
I don't think a grep helps here. There's plenty of reasons the string HOSTNAME might show up in an executable that have little to do with environment variables.
|
|
|
08-23-2014, 08:32 PM
|
#5
|
Senior Member
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 1,038
|
Quote:
Originally Posted by GazL
I don't think a grep helps here. There's plenty of reasons the string HOSTNAME might show up in an executable that have little to do with environment variables.
|
It turns out that you're right. Grepping the sources shows that only some of them use HOSTNAME as a reference to the environment variable.
Code:
n/netwatch/netwatch-1.3.0-1.tar.gz: if ((hostp = getenv ("HOSTNAME")) == NULL)
n/newspost/newspost-2.1.1.tar.gz: envopt2 = getenv("HOSTNAME");
n/sendmail/sendmail.8.14.7.tar.gz: APPENDDEF(`conf_sendmail_ENVDEF', `-DNEEDLOCAL_HOSTNAME_LENGTH=0')
sh/bash-4.1.tar.gz:(@env{HOSTTYPE}, @env{OSTYPE}, @env{MACHTYPE}, and @env{HOSTNAME}),
sh/bash-4.1.tar.gz:`HOSTNAME'
sh/bash-4.1.tar.gz: host (`HOSTTYPE', `OSTYPE', `MACHTYPE', and `HOSTNAME'), and the
sh/bash-4.1.tar.gz:* HOSTNAME: Bash Variables. (line 339)
octave/archive/octave-3.2.4.tar.gz: host = getenv("HOSTNAME");
ttk@spork:~/tools/slackware/sw141/source> find -name "*.tar.bz2" -print -exec /bin/sh -c 'bzcat {} | grep -a HOSTNAME | grep -i env' \; | /usr/bin/less -X
./ap/jed/jed-0.99-19.tar.bz2
b = getenv ("HOSTNAME");
ttk@spork:~/tools/slackware/sw141/source> find -name "*.tar.xz" -print -exec /bin/sh -c 'xzcat {} | grep -a HOSTNAME | grep -ai env' \; | /usr/bin/less -X
./a/tcsh/tcsh-6.18.01.tar.xz
setenv HOSTNAME $COMPUTERNAME
./ap/joe/joe-3.7.tar.xz
unsigned char *host = (unsigned char *)getenv("HOSTNAME");
./ap/mariadb/mariadb-5.5.32.tar.xz
theEnvHostNamePtr = NdbEnv_GetEnv("HOSTNAME", buf, 255);
./d/distcc/distcc-3.1.tar.xz
envh2 = getenv("HOSTNAME");
./d/guile/guile-2.0.9.tar.xz
char *s = getenv ("HOSTNAME");
./d/subversion/subversion-1.7.13.tar.xz
os.environ['HOSTNAME'],
./kde/src/kdesdk-4.10.5.tar.xz
(concat (getenv "LOGNAME") "@" (getenv "HOSTNAME"))
./kde/src/kdelibs-4.10.5.tar.xz
local_file_3.setHost(getenv("HOSTNAME"));
./l/glib2/glib-2.36.4.tar.xz
session_bus_address = g_getenv ("HOSTNAME");
./l/libcddb/libcddb-1.3.2.tar.xz
to the value of the 'HOSTNAME' environment
$USER and $HOSTNAME environment variables if they were present.
./n/mutt/mutt-1.5.22.tar.xz
if the environment variable $HOSTNAME is set to ?kremvax.? (See $record for
./n/slrn/slrn-1.0.1.tar.xz
if ((NULL != (host1 = getenv ("HOSTNAME")))
./n/tin/tin-2.0.1.tar.xz
if ((ptr = getenv("HOSTNAME")) != NULL)
./xap/windowmaker/WindowMaker-0.95.5.tar.xz
h = getenv("HOSTNAME");
so .. not as many as I thought, but some.
|
|
2 members found this post helpful.
|
08-24-2014, 06:53 AM
|
#6
|
LQ Veteran
Registered: May 2008
Posts: 7,053
Original Poster
|
Thanks for that, ttk. I should have probably done that myself.
Looking at the 'jed' code, it does this:
Code:
if ((-1 == gethostname (buf, sizeof (buf)))
|| (*buf == 0))
{
b = getenv ("HOSTNAME");
if ((b == NULL) || (*b == 0))
return NULL;
}
... so the environment variable is just a fallback.
The 'distcc' code seems to be doing all manner of weird things rather than just calling gethostname(), but again the getenv() call is just one of many things it tries.
The 'guile' one just seems to be an example function in the documentation.
I didn't check any of the others, but I wouldn't be surprised to find that its mostly just a fallback mechanisn for when gethostname() isn't there.
Anyway, what sparked all of this off was that I was reviewing the contents of my /etc/profile to see what could be safely cleared out, and wondered what prompted HOSTNAME= to be added to it in the first place. I suspect it'll turn out to be one of those reasons that has been lost in time.
Last edited by GazL; 08-24-2014 at 06:56 AM.
|
|
|
All times are GMT -5. The time now is 03:36 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|