Best of Technical Support

Our experts answer your technical questions.
You Can't Log in Now; Get a Life

I have a couple of questions. First, how would you create a backup user for root with the same privileges as root? Second, is there a way to allow users to log in only within a specific time frame? An example of this would be to allow a user to log in between the hours of 6 A.M. and 6 P.M., but not to allow logins outside of this window.

—Jerry Fulkerson, hrlinkin@aol.com

To add a second root account, edit /etc/passwd and /etc/shadow (using vipw and vipw -s). In both files, duplicate the line with root and change the name to backuproot.

—Marc Merlin, marc_bts@valinux.com

Regarding control of login time, there are several ways of doing it. Using the Pluggable Authentication Modules (PAM) system's pam_time module is one of them, for instance. The file /etc/security/time.conf could have the line:

login;*;joe;Al0600-1800

This means the user joe is allowed to use the service called login, from any terminal (*), all days (Al) only during 06:00 and 18:00 hours. Be aware that this requires the entry:

login   account required   pam_time.so

on the PAM configuration file, which is usually at /etc/pam.conf or alternatively, the file named login to be within /etc/pam.d/ and containing:

account required pam_time.so

A good PAM reference can be found at www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/pam.html#toc4.

—Felipe E. Barousse Boué, fbarousse@piensa.com

I Have No DHCP and I Must Network

Currently, I use Red Hat 7.0 on PCs in my computer programming lab. These computers use DHCP to connect to the building network and the Internet. Recently I attempted to upgrade these machines to a stock version of Red Hat 7.2. I have been unable to get computers to connect via DHCP. I have tried to configure the card and networking using the various GUI tools but have had no success.

—Bill Hummel, hummelb@readingsd.org

Looks to me that you are having trouble connecting because of two possible issues. First, you have not configured the DHCP client to connect to the network. I just did it on a Red Hat 7.2 machine by having the minimally configured file /etc/sysconfig/network-scripts/ifcfg-eth0 for network interface eth0 as:

DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"

This will provide enough information for the system to boot up, and when starting networking facilities, to look for an IP address provided by a DCHP server. Second, you probably set a firewall or network filter that is not allowing DHCP to work properly. Did you request a “high” security level when installing? Just one time, get rid of the ipchains setup that Red Hat 7.2 sets up by commenting all lines in /etc/sysconfig/ipchains and then try step one.

—Felipe E. Barousse Boué, fbarousse@piensa.com

What Does ./ Mean?

When (and why) is it necessary to put ./ in the beginning of a command line?

—Murray Zangen, murray@nj.com

The ./ means current working directory. You need to put ./ in front only when you want to run a program in the directory you are in, and that directory is not in the PATH shell variable ($PATH).

—Usman Ansari, uansari@yahoo.com

The reason the current directory is not in the path is due to security concerns. If an adversary installed a Trojan ls command in the /tmp directory and you cd-ed into /tmp and typed ls, you would run the adversary's program. If you really don't like having to type ./, place the current directory at the *end* of your PATH shell variable, this will make your file system surfing safer.

—Christopher Wingert, cwingert@qualcomm.com

Opening a File with filep_open

I have created a configuration file stored in the directory /etc. I have been trying to open this file from a C program without success:

struct file     *filp;
char *Filename = "/etc/pg.conf\0";
filp = filp_open(Filename,00,O_RDONLY);
if (IS_ERR(filp)||(filp==NULL))
        return;

Could someone advise me how to fix this?

—Senthil, senthil@singnet.com.sg

I believe that you do not have the parameters correct to filp_open(). Try

filp = filp_open( Filename, O_RDONLY, 0 );

—Christopher Wingert, cwingert@qualcomm.com

______________________

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot