LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Variables Used in Banners (https://www.linuxquestions.org/questions/linux-newbie-8/variables-used-in-banners-378674/)

Palula 10-31-2005 01:33 PM

Variables Used in Banners
 
Iīm not sure but I think this post belongs to another section of the forum branch like, for example, the general or distro sections because I donīt think this post regards anything relevant to specific programs. Well... Anyway...

Iīm using vsftpd an I want to create a customized banner for logging users. And the thing is, I saw somewhere that the Unix bash recognizes specific variables that can represent pre-formatted environmental info. Like for example, "%u" represents the username (I think)...

I would like to create a nicely customized banner that can show the userīs name, his/her IP address and many other things that can be done with these variables.

Does anyone have a list of those? Iīve looked for some in google but I didnīt find any, except the "%u". Is "%u" all there is?

Thanks a lot!

MensaWater 11-01-2005 07:19 AM

This is a little confused. You talke about vsftp, bash, parameters, banners and logging all at once.

I don't use vsftp but I'm if its like the other ftp variants it has its own shell and doesn't use the user shell (usually bash) defined in /etc/passwd for a user. That shell is used on logins using telnet, ssh or direct logins such as on the console not on ftp/scp transfers.

%u has no meaning within the shell. In fact the only thing I can think of off the top of my head that defines things with "%" is the date command. "date +%u" would return the day of the week. There is a subformat within one of the bash variable for %U but not %u (case is significant in UNIX/Linux).

What you are calling parameters is more properly called variables. Bash does have several predefined ones (HOME & PS1 for example). To see all the ones defined do "man bash" then locate "Shell Variables". To reference a variable you use the dollar sign ($) not the percent sign (%) so to call the HOME variable you call it $HOME.

I'm not sure what you mean by "banner". A banner would be something that displays on the screen but I don't know why you'd want to banner a user's own session back to them. I suspect you mean instead you'd like to be able to log the user's information.

For standard logins just doing the "who" command will give you the login ID, the tty, the time of login and the IP or hostname from which it came for all logins. Doing "who am i" on the user's terminal will show just that user's information. You can also use the "finger" command to see information for specific users by following it with the user's login ID.

Note the above is for normal ssh/telnet/direct logins. The ftp setup does not use that methodology so has a limited set of commands some of which have the same name (e.g. pwd, ls) as those used in the shells but are not actually the same.

Use the "man" command for details on any command on whichy you need more info examples for the commands I've mentioned above:

"man bash"
"man vsftp"
"man ftp"
"man who"
"man finger"
"man date"

Palula 11-01-2005 10:46 AM

Iīm a bit confused. Iīll try to explain:

When I say banner, I mean something like this:

Code:

----------------------------
        Welcome
----------------------------

Use of this system constitutes consent to security monitoring and testing.
All activity is logged with your host name and IP address.

 Hi (user)@(domain).
 Your IP adress is: (IP adress).
 Local Time is: (local time).
 Average throughput for this server is: (avgthroughput).
 (numpeople) have visited this server in the last 24 hours.

Everything in parenthesis should be a bash variable (if possible).

Palula 11-03-2005 08:55 AM

Here is another concern of me? Besides the one regarding the banner (wich I donīt have clue yet)...

Files can be uploaded to my FTP from the logged users. How can I create a default permission for uploaded files to be:
- write and read by the owner
- read by the group
- read by others
(Never execute)

The mask should be: 644 for all files right?
I want this to be the regular upload mask for all files uploaded to my FTP.

Just for the record. The uploads Iīve done so far, canīt be executed anyway. But how can I know for sure, executing files is prohibited?

Thanks a lot.


All times are GMT -5. The time now is 12:55 AM.