[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: invoke tilde expansion on quoted string
From: |
Greg Wooledge |
Subject: |
Re: invoke tilde expansion on quoted string |
Date: |
Tue, 9 Apr 2013 08:46:52 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Apr 08, 2013 at 05:13:46PM -0700, Linda Walsh wrote:
> Greg Wooledge wrote:
> > getent(1) is fine where it's available, but it's not a standard tool,
> > so you can only use it on systems that have it.
> Have you encountered it on other linux systems?
It is present on Debian 3.1 (the oldest Debian system to which I have
access), OpenBSD 5.2, and Red Hat Enterprise Linux 5.7. It would require
some digging to find out exactly when it first appeared on each of those
operating systems.
For comparison, it is NOT present on Red Hat 5.2 ("Apollo"). The one
from the 1990s, not RHEL 5.2. I utterly despise the fact that it takes
me three sentences to explain a version number.
> Certainly, I'd think that parsing /etc/passwd would be more portable as
> it could likely be adapted to the other methods given programs that
> are similar to getent that provide database entries (passwd lines)
> like with yp/nis.
That's just asking for trouble. I don't know every arcane Unix
authentication system out there, but I'd imagine at least one of them
can't be used that way. Plus, there's the issue of determining which
authentication system you're actually supposed to pull the account
information from.
imadev:~$ grep '^wooledg' /etc/passwd
Oh, look. I'm not in /etc/passwd. No, wait, maybe I am:
imadev:~$ grep '+\{0,1\}wooledg' /etc/passwd
+wooledg::-24:-24:::/usr/local/bin/bash
Right, the plus sign means I'm really in NIS:
imadev:~$ ypmatch wooledg passwd.byname | awk -F: '{$2="xxxx"; OFS=":"; print}'
wooledg:xxxx:563:22:Greg Wooledge:/net/home/wooledg:/bin/ksh
So to get my home directory by mimicking the operating system's account
lookup procedures, I have to make at least 3 separate checks, and I may
have to merge data from 2 of those.
P.S. /net/home/wooledg is another virtualization. At the shell level
it can be used as if it were a literal directory. If you wanted the
physical location you'd either have to cd there and then ask where
you really are, or do yet another NIS lookup and parsing.
I don't know how NIS+ or LDAP work, but I know they're even more
complicated than NIS.
Now you can see why I decided that eval "home=~$sanitized_username"
was the better choice.
- Re: invoke tilde expansion on quoted string, Eric Blake, 2013/04/04
- Re: invoke tilde expansion on quoted string, Chris Down, 2013/04/04
- Re: invoke tilde expansion on quoted string, Greg Wooledge, 2013/04/04
- Re: invoke tilde expansion on quoted string, Eric Blake, 2013/04/04
- Re: invoke tilde expansion on quoted string, Linda Walsh, 2013/04/07
- Re: invoke tilde expansion on quoted string, Greg Wooledge, 2013/04/08
- Re: invoke tilde expansion on quoted string, Linda Walsh, 2013/04/08
- Re: invoke tilde expansion on quoted string,
Greg Wooledge <=
- Re: invoke tilde expansion on quoted string, Bob Proulx, 2013/04/09
- Re: invoke tilde expansion on quoted string, Greg Wooledge, 2013/04/09