Author Topic: ENV defined where  (Read 3383 times)

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« on: August 11, 2004, 05:48:21 pm »
Anyone know where the environment for the zaurus user is defined? Trying to figure out when the SHELL=/bin/bash, while the /etc/passwd entry says /bin/sh

Thanks,

gdog
You can tell a lot about a man by the condition of his shoes

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
ENV defined where
« Reply #1 on: August 11, 2004, 07:43:54 pm »
SHELL comes from /etc/passswd - the last entry in the users line. most other ENV values come from /etc/profile or ~/.bashrc or ~/.profile

Change "/bin/sh" to "/bin/bash" in /etc/passwd and you will get command completion too.

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« Reply #2 on: August 11, 2004, 08:34:24 pm »
Don't think so in this case Stu. Shell in both shadow and passwd is /bin/sh, but when I open a terminal session the shell for zaurus is /bin/bash. I had installed a .bashrc file but just switched to konsole and found that it reads the .profile but not .bashrc so I changed that.

What I'm trying to do is get the tab key completion working for root without having to actually execute the bash command. Any ideas?

konsole is way cool! This little box is starting to resemble my workstation more and more each day  

Thanks,

gdog
« Last Edit: August 11, 2004, 08:35:15 pm by gdog »
You can tell a lot about a man by the condition of his shoes

doseas

  • Full Member
  • ***
  • Posts: 207
    • View Profile
    • http://
ENV defined where
« Reply #3 on: August 12, 2004, 02:36:50 pm »
Stu is correct that the shell comes from /etc/passwd.  Try telnet'ing into the Zaurus & you'll see.

The reason you get the Bash shell from Qtopia as user zaurus is that the file that starts Qtopia (/home/QtPalmtop/qpe.sh) sets the SHELL environment variable early on:
export SHELL=/bin/bash

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« Reply #4 on: August 12, 2004, 05:55:59 pm »
Quote
Stu is correct that the shell comes from /etc/passwd.  Try telnet'ing into the Zaurus & you'll see.

The reason you get the Bash shell from Qtopia as user zaurus is that the file that starts Qtopia (/home/QtPalmtop/qpe.sh) sets the SHELL environment variable early on:
export SHELL=/bin/bash
With all due respect, in this case Stu is not. I'm not a Linux or Unix newbie, though I am very new to the Zaurus. The shell for zaurus as defined in /etc/passwd is /bin/sh (on my system). And I've already found the qpe.sh file and seen that the SHELL var is indeed set as /bin/bash there. But that in itself does not provide tab completion. If it did, and I then set the SHELL variable for root from the command line, or the .profile, root would have tab completion as well. But it doesn't. I have to actually start a bash shell as root by executing bash before tab completion works for it.

I have noticed that the Z does some weird things with the passwd file. And things that are normally easy to do in Unix/Linux, such as editing it manually and then refreshing shadow by doing a pwconv are not possible with the Z. There are also two instances of the passwd file, one in /home/etc/passwd (equiv. of /etc/passwd), and one in /root/etc/passwd. The latter does not even contain an entry for zaurus.

So no disrespect intended, and while I fully acknowledge that Stu is very learned on these devices while I am not, in this case it certainly appears as if there is something other than a passwd entry (or the SHELL var in qpe.sh), that is providing tab completion. My goal is to find out what  

Regards,

gdog
You can tell a lot about a man by the condition of his shoes

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
ENV defined where
« Reply #5 on: August 12, 2004, 08:11:10 pm »
Quote
Don't think so in this case Stu. Shell in both shadow and passwd is /bin/sh, but when I open a terminal session the shell for zaurus is /bin/bash. I had installed a .bashrc file but just switched to konsole and found that it reads the .profile but not .bashrc so I changed that.

You shouldn't have a shell line in shadow! My shadow for zaurus looks like this.
Code: [Select]
zaurus::10933:0:99999:7:::Yes, your shell in /etc/passwd for zaurus is /bin/sh, but the terminal app opens as bash because the qpe.sh sets the shell for zaurus (not root) to /bin/bash and some of the terminal apps are hardcoded to start with bash shell. When you su to root, it does not read the root .profile or .bashrc because su is actually tinylogin. You could try "su -" to read .profile, but cant remember if it works as it should. Actually su on my gentoo box works this way, if I just use "su" then I become root, but it doesn't run .bashrc or .profile for root, if I want full root env I need to run "su -".

Quote
What I'm trying to do is get the tab key completion working for root without having to actually execute the bash command. Any ideas?

The easiest way is to edit /etc/passwd as I mentioned in my first post - try it I bet it works (actually I know it works cause I did it myself)

NOTE: qpe.sh is only run at boot time and seems to only set env variables for user zaurus. I'm not sure why that is, but that is what happens on my C760.

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« Reply #6 on: August 12, 2004, 08:42:44 pm »
Stu,
I don't have a shell line in the shadow file. That was an misstatement caused by my haste in posting.

Quote
Yes, your shell in /etc/passwd for zaurus is /bin/sh, but the terminal app opens as bash because the qpe.sh sets the shell for zaurus (not root) to /bin/bash
[\quote]

This I know (about qpe.sh), but setting the shell to bash in root's .profile does not accomplish the same thing. The SHELL does indeed become bash, but tab completion is not there.

Quote
and some of the terminal apps are hardcoded to start with bash shell.
[\quote]

This may in fact be the reason why tab completion is there for zaurus in Terminal. If in fact bash is being "executed" as part of the preparation for user zaurus, by qpe when Terminal starts that would explain it.

Quote
When you su to root, it does not read the root .profile or .bashrc because su is actually tinylogin. You could try "su -" to read .profile, but cant remember if it works as it should.
[\quote]

Yes indeed using su - does in fact result in the .profile being read, and the env as a whole becoming root's just as one would expect. But regardless of the fact that I do have a export SHELL=/bin/bash statement in .profile for root, and in spite of the fact that it does reset root's shell to bash (from the /etc/passwd provided /bin/sh, it does not also provide tab completion. Bummer days. But I guess I'll just have to keep executing it from the command line after becoming root, though I may try to do something exotic like executing it in the background from the .profile just to see if that will work.

I hope you have not taken offense to my disagreeing with you. I know how much help you are to others, and have already been to me, and I can assure you that no offense is intended.

Thanks for the reply,

Regards,

gdog
« Last Edit: August 12, 2004, 08:44:07 pm by gdog »
You can tell a lot about a man by the condition of his shoes

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
ENV defined where
« Reply #7 on: August 13, 2004, 10:51:28 am »
Quote
Yes indeed using su - does in fact result in the .profile being read, and the env as a whole becoming root's just as one would expect. But regardless of the fact that I do have a export SHELL=/bin/bash statement in .profile for root, and in spite of the fact that it does reset root's shell to bash (from the /etc/passwd provided /bin/sh, it does not also provide tab completion. Bummer days. But I guess I'll just have to keep executing it from the command line after becoming root, though I may try to do something exotic like executing it in the background from the .profile just to see if that will work.
I think that setting it in .profile is too late, because it is being read after the shell is started and by then it is already running sh.

I really suggest trying my suggestion of changing root's shell in /etc/passwd - it will do what you want.

Quote
I hope you have not taken offense to my disagreeing with you. I know how much help you are to others, and have already been to me, and I can assure you that no offense is intended.

Thanks for the reply,

Non taken, I would never learn anything if everybody always agreed with me

I actually haven't done much indepth looking at where the SHELL env is set, after trying .profile and having on luck, I changed /etc/passwd and it worked - since then I haven't really looked any further for it. But the zaurus definetly does some non-standard stuff with the filesystem and ENV variables.

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« Reply #8 on: August 13, 2004, 12:49:49 pm »
Stu,
There's an old sysadmin fear about using "non-standard" shells for root because of the potential for the shell not being there in single user mode if the fs on which it resides is not mounted. But in this case since both sh (ash) and bash are in /bin then I don't think that's a danger.

Just out of curiosity, and because I've not been entirely successful yet in doing most anything with the passwd file, do I need to do anything fancy to get my modifications to the existing entries to stick?

Thanks, and I'm glad you're ok with debate!

Regards,

gdog
You can tell a lot about a man by the condition of his shoes

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
ENV defined where
« Reply #9 on: August 14, 2004, 08:26:34 am »
Quote
There's an old sysadmin fear about using "non-standard" shells for root because of the potential for the shell not being there in single user mode if the fs on which it resides is not mounted.

Yeah, the same thing came up on the gentoo development list in the early days, but the majority seemed to think that bash is the standard for linux, and I can't remember it being installed anywhere but /bin in the linux distros I've used.

Quote
Just out of curiosity, and because I've not been entirely successful yet in doing most anything with the passwd file, do I need to do anything fancy to get my modifications to the existing entries to stick?

All I did was fire up vi and edit root and zaurus's lines in /etc/passwd and save the file. Never did anything else with it.

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

gdog

  • Full Member
  • ***
  • Posts: 246
    • View Profile
ENV defined where
« Reply #10 on: August 14, 2004, 08:56:09 am »
When I first got my Zaurus I tried creating a new user by manually editing the passwd file. It never quite took, mostly I think because I wasn't using adduser, and therefore shadow wasn't being updated. Be nice to have a pwconv command...

I edited the entries for both zaurus and root, providing each with /bin/bash and it seems to be working fine. root has tab completion and zaurus appears unchanged.

BTW Stu I saw your name on another board in which you participated in a topic regarding keeping the root shell intact after a Suspend and Resume. Can't recall if it was you that suggested using exec su for that purpose, but it worked for me.

It's amazing how much information is out there, some of which makes this little linux "workstation" one mighty fine mobile tool!

Thanks again for your help Stu!

Regards,

gdog
You can tell a lot about a man by the condition of his shoes