LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-27-2015, 03:52 PM   #1
c94p67
LQ Newbie
 
Registered: Aug 2014
Posts: 16

Rep: Reputation: Disabled
Question MOTD script not running for normal user


I have a MOTD script that wont execute for normal users, instead it only gets echoed. It works for root though. What am i missing here?
I did try and chmod +x /etc/motd to no avail.
 
Old 01-27-2015, 04:46 PM   #2
j_v
Member
 
Registered: Oct 2011
Distribution: Slackware64
Posts: 364

Rep: Reputation: 67
First, I suggest reading the man pages for login and login.defs. Check /etc/login.defs for definition of HUSHLOGIN_FILE and then check for that file. If the HUSHLOGIN_FILE variable in /etc/login.defs is a full path, then it will hush login chatter if the user's name or shell are found in the file; if not a full path, then the mere existence of the named file in the user's home directory will hush login chatter.

Cheers
 
Old 01-27-2015, 06:05 PM   #3
c94p67
LQ Newbie
 
Registered: Aug 2014
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by j_v View Post
First, I suggest reading the man pages for login and login.defs. Check /etc/login.defs for definition of HUSHLOGIN_FILE and then check for that file. If the HUSHLOGIN_FILE variable in /etc/login.defs is a full path, then it will hush login chatter if the user's name or shell are found in the file; if not a full path, then the mere existence of the named file in the user's home directory will hush login chatter.

Cheers
There seems to be some miscommunication here.

My goal here is not to silence the login, but to have the MOTD execute with scripts in it. EG. Welcome back, `whoami`

This works perfectly fine when i login to the root account, but for normal users the result is "Welcome back, `whoami`"
 
Old 01-27-2015, 06:29 PM   #4
j_v
Member
 
Registered: Oct 2011
Distribution: Slackware64
Posts: 364

Rep: Reputation: 67
Ah. I've never heard of a motd `script`. Documentation I've read mentions that the MOTD file(s) will be displayed, not executed. I did not read your issue correctly, true. I inferred that the motd wasn't being displayed. Was trying to point out ways in which you could find out if motd was already being hushed (obviously not the problem). If you want some specific scripts to run on login, perhaps look at adding them to /etc/profile.
 
Old 01-27-2015, 08:34 PM   #5
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
You could try setting LOGIN_STRING. See "man login"
 
Old 01-27-2015, 08:41 PM   #6
j_v
Member
 
Registered: Oct 2011
Distribution: Slackware64
Posts: 364

Rep: Reputation: 67
Setting LOGIN_STRING will set the prompt string. Default is "Passord: ". MOTD is for after successful login.
 
Old 01-27-2015, 09:16 PM   #7
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,055

Rep: Reputation: Disabled
Quote:
Originally Posted by c94p67 View Post
My goal here is not to silence the login, but to have the MOTD execute with scripts in it. EG. Welcome back, `whoami`
AFAIK this has always been the purpose of /etc/issue.

EDIT. statement above was wrong, see next post from j_v.

That's one also (a specific version) among the first things you see when you install Slackware.

Oh and a reminder for newcomers who could happen to read this: there are messages that one get only in a login shell, e.g. running "su -" instead "su", like the one displayed by "fortune" if bsd-games is installed.

Last edited by Didier Spaier; 01-28-2015 at 04:01 AM. Reason: EDIT added.
 
Old 01-27-2015, 09:37 PM   #8
j_v
Member
 
Registered: Oct 2011
Distribution: Slackware64
Posts: 364

Rep: Reputation: 67
/etc/issue is displayed before the password prompt, not after successful login. Defined by ISSUE_FILE in /etc/login.defs.
 
1 members found this post helpful.
Old 01-28-2015, 03:57 AM   #9
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,055

Rep: Reputation: Disabled
Quote:
Originally Posted by j_v View Post
/etc/issue is displayed before the password prompt, not after successful login. Defined by ISSUE_FILE in /etc/login.defs.
Hmm... Posting by night is not a valid excuse, I should have checked. Thanks!
 
Old 01-28-2015, 04:17 AM   #10
c94p67
LQ Newbie
 
Registered: Aug 2014
Posts: 16

Original Poster
Rep: Reputation: Disabled
I must be terrible at explaining my self. I dont understand why this is such a big problem hehe.

I will therefor show you want i want and what i actually get.

Code:
           o888                       oooo        oooo          ooooooo
 oooooooo8  888   ooooooo    ooooooo   888  ooooo  888ooooo   o888  o888o oooo   oooo
888ooooooo  888   ooooo888 888     888 888o888     888    888 888  8  888   888o888
        888 888 888    888 888         8888 88o    888    888 888o8  o888   o88 88o
88oooooo88 o888o 88ooo88 8o  88ooo888 o888o o888o o888ooo88     88ooo88   o88o   o88o 


+++++++++++++++++: System Data :++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Hostname = slackbox
+ Address  = 0.0.0.0
+ Kernel   = 3.10.17
+ Uptime   = 10:10:14 up 1 day, 15:18,  1 user,  load average: 0.13, 0.05, 0.05
+ CPU      = Intel(R) Atom(TM) CPU  C2750  @ 2.40GHz
+ Memory   = 8147008 kB
++++++++++++++++++: User Data :+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Enjoy your stay, root
As you can see above, this is what my MOTD looks like when i log in as root. This is what i want.
However, when i log in as a normal user, i get the following;

Code:
#!/bin/bash

echo -e "

           o888                       oooo        oooo          ooooooo
 oooooooo8  888   ooooooo    ooooooo   888  ooooo  888ooooo   o888  o888o oooo   oooo
888ooooooo  888   ooooo888 888     888 888o888     888    888 888  8  888   888o888
        888 888 888    888 888         8888 88o    888    888 888o8  o888   o88 88o
88oooooo88 o888o 88ooo88 8o  88ooo888 o888o o888o o888ooo88     88ooo88   o88o   o88o 


+++++++++++++++++: System Data :++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Hostname = `hostname`
+ Address  = 0.0.0.0
+ Kernel   = `uname -r`
+ Uptime   =`uptime | sed 's/.*up ([^,]*), .*/1/'`
+ CPU      = `cat /proc/cpuinfo | grep Atom`
+ Memory   = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB
++++++++++++++++++: User Data :+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Enjoy your stay, `whoami`
"
As you can see, the scripts are not being executed, but rather echoed to the buffer as if it is interpreting it as literal text.
 
Old 01-28-2015, 04:31 AM   #11
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,055

Rep: Reputation: Disabled
What is really strange is that the script be executed when you log in as root: it shouldn't, and it is not here.

Please read "man motd". As j_v pointed out, if you want that this script be executed at each login you should put it elsewhere. /etc/motd should be just a message displayed as-is.

Last edited by Didier Spaier; 01-28-2015 at 04:32 AM.
 
Old 01-28-2015, 05:28 AM   #12
c94p67
LQ Newbie
 
Registered: Aug 2014
Posts: 16

Original Poster
Rep: Reputation: Disabled
solb

Quote:
Originally Posted by Didier Spaier View Post
What is really strange is that the script be executed when you log in as root: it shouldn't, and it is not here.

Please read "man motd". As j_v pointed out, if you want that this script be executed at each login you should put it elsewhere. /etc/motd should be just a message displayed as-is.
The reason it is being exectuted for for root, is because i did chmod +x /etc/motd. I am wanting the +x attribute to apply for users as well. But for now im fine with hushlogin and calling the script from .bashrc.

Thanks.
 
Old 01-28-2015, 05:33 AM   #13
MadMaverick9
Member
 
Registered: Aug 2010
Posts: 353
Blog Entries: 4

Rep: Reputation: Disabled
Can you please execute:
Code:
grep -ir motd /etc/ 2>/dev/null
and copy/paste the complete output here, please.

Last edited by MadMaverick9; 01-28-2015 at 05:38 AM. Reason: Add "-i" flag.
 
Old 01-28-2015, 05:40 AM   #14
c94p67
LQ Newbie
 
Registered: Aug 2014
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadMaverick9 View Post
Can you please execute:
Code:
grep -ir motd /etc/ 2>/dev/null
and copy/paste the complete output here, please.
/etc/rc.d/rc.S.orig:# Update the current kernel level in the /etc/motd (Message Of The Day) file,
/etc/rc.d/rc.S.orig: /bin/sed -i "{1s/^Linux.*/$(/bin/uname -sr)\./}" /etc/motd
/etc/rc.d/rc.S:# Update the current kernel level in the /etc/motd (Message Of The Day) file,
/etc/rc.d/rc.S: /bin/sed -i "{1s/^Linux.*/$(/bin/uname -sr)\./}" /etc/motd
/etc/login.defs:MOTD_FILE /etc/motd
/etc/login.defs:#MOTD_FILE /etc/motd:/usr/lib/news/news-motd
/etc/X11/app-defaults/XLock:!XLock.messagefile: /etc/motd
/etc/ssh/sshd_config.orig:#PrintMotd yes
/etc/ssh/sshd_config:#PrintMotd yes

Last edited by c94p67; 01-28-2015 at 05:48 AM. Reason: with-ir
 
Old 01-28-2015, 06:06 AM   #15
MadMaverick9
Member
 
Registered: Aug 2010
Posts: 353
Blog Entries: 4

Rep: Reputation: Disabled
shadow-4.2.1.tar.xz:/shadow-4.2.1/libmisc/motd.c:
Code:
                fp = fopen (motdfile, "r");
                if (NULL != fp) {
                        while ((c = getc (fp)) != EOF) {
                                putchar (c);
                        }
                        fclose (fp);
                }
It is technically impossible that "/etc/motd" is executed as a script, unless you are doing so from "/etc/profile" or "/etc/profile.d/" or doing something else.

What version of Slackware are you running?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
super user privileges check for a normal user in bash script freeindy Programming 2 08-01-2008 06:08 AM
ambiguous redirect when running a script in /root/bin with sudo as normal user chadwick Linux - General 2 06-01-2007 09:57 AM
Running super user commands as normal user mickyg Linux - Security 5 10-14-2005 07:25 PM
normal user running shutdown cblamer Slackware 6 12-21-2003 08:44 PM
running ethereal as a normal user tangle Linux - Software 1 02-04-2003 09:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration