LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   MOTD script not running for normal user (https://www.linuxquestions.org/questions/slackware-14/motd-script-not-running-for-normal-user-4175532237/)

c94p67 01-27-2015 03:52 PM

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.

j_v 01-27-2015 04:46 PM

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

c94p67 01-27-2015 06:05 PM

Quote:

Originally Posted by j_v (Post 5307482)
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`"

j_v 01-27-2015 06:29 PM

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.

Richard Cranium 01-27-2015 08:34 PM

You could try setting LOGIN_STRING. See "man login"

j_v 01-27-2015 08:41 PM

Setting LOGIN_STRING will set the prompt string. Default is "Passord: ". MOTD is for after successful login.

Didier Spaier 01-27-2015 09:16 PM

Quote:

Originally Posted by c94p67 (Post 5307512)
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.

j_v 01-27-2015 09:37 PM

/etc/issue is displayed before the password prompt, not after successful login. Defined by ISSUE_FILE in /etc/login.defs.

Didier Spaier 01-28-2015 03:57 AM

Quote:

Originally Posted by j_v (Post 5307571)
/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!

c94p67 01-28-2015 04:17 AM

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.

Didier Spaier 01-28-2015 04:31 AM

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.

c94p67 01-28-2015 05:28 AM

solb
 
Quote:

Originally Posted by Didier Spaier (Post 5307664)
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.

MadMaverick9 01-28-2015 05:33 AM

Can you please execute:
Code:

grep -ir motd /etc/ 2>/dev/null
and copy/paste the complete output here, please.

c94p67 01-28-2015 05:40 AM

Quote:

Originally Posted by MadMaverick9 (Post 5307690)
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

MadMaverick9 01-28-2015 06:06 AM

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?


All times are GMT -5. The time now is 11:40 PM.