Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 147605

Summary: [net-misc/openssh=4.3_p2] breaks w/ slashes in usernames
Product: Gentoo Linux Reporter: Enrico 'nekrad' Weigelt <weigelt>
Component: Current packagesAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: VERIFIED INVALID    
Severity: normal CC: beu, sgtphou, spb, thedude0001
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard: gentoo patch openssh_4.3_p2.selinux.patch introduces the fault. fixed version attached.
Package list:
Runtime testing required: ---
Attachments: fixed version of openssh-4.3_p2-selinux.patch
openssh-4.3_p2-selinux-metux.patch

Description Enrico 'nekrad' Weigelt 2006-09-14 13:20:16 UTC
Breaks w/ slashes in usernames. According to syslog, it cuts off the username at the slash.

Older version (ie. tested w/ 3.7) work cleanly.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 13:27:03 UTC
man useradd
<snip>
Usernames must begin with a lower case letter or an underscore, and only lower case letters, underscores, dashes, and dollar signs may follow. In regular expression terms: [a-z_][a-z0-9_-]*[$]
</snip>

Comment 2 Enrico 'nekrad' Weigelt 2006-09-14 14:38:54 UTC
I've now tracked it down:
It is an gentoo patch, which explicitly custs off the username at an '/'.

But I didn't find out yet where this patch actually comes from - emerge -f doesn't seem to download it.
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 14:47:01 UTC
Your username is illegal, period.
Comment 4 Enrico 'nekrad' Weigelt 2006-09-14 14:53:59 UTC
It worked for almost ten years now. In fact several hundreds of them now worked for almost ten years. And it still works on non-gentoo systems. 

It is an gentoo-specific problem. 

Now could you please help me in fixing this ?
Where does the patch actually come from ?


Comment 5 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 14:55:28 UTC
# useradd ab/cd
useradd: invalid user name 'ab/cd'

Comment 6 Enrico 'nekrad' Weigelt 2006-09-14 15:07:39 UTC
Yes, gentoo's usedadd also refuses slashes, so I had to take it from another (non-gentoo) system. Evrything else works properly.

I still dont see, why an gentoo-specific patch explicitly breaks usernames with slashes. Any *good* explaination, why this is *necessary* ?


Comment 7 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 15:09:37 UTC
Kindly read the above manpage.
Comment 8 Elfyn McBratney (beu) (RETIRED) gentoo-dev 2006-09-14 16:39:19 UTC
Enrico,

You keep insisting that a Gentoo-provided patch results in this behaviour (the disallowing of '\' in a login name); please either show us this patch, or shut up.  And I'm pretty sure you won't be able to as no patches are applied to sys-apps/shadow that explicitly disallow this.  Therefore, this is an upstream problem - go pester them.

Thanks,
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 16:54:48 UTC
There's no Gentoo-specific patch that forbids the retarded / character in username. Go unpack vanilla sys-apps/shadow tarball from distfiles and read the code. Especially read libmisc/chkname.c

<snip>
static int good_name (const char *name)
{
        /*
         * User/group names must match [a-z_][a-z0-9_-]*[$]
         */
        if (!*name || !((*name >= 'a' && *name <= 'z') || *name == '_'))
                return 0;

        while (*++name) {
                if (!((*name >= 'a' && *name <= 'z') ||
                      (*name >= '0' && *name <= '9') ||
                      *name == '_' || *name == '-' ||
                      (*name == '$' && *(name + 1) == '\0')))
                        return 0;
        }

        return 1;
}

This bug is plain invalid, / is NOT a legal character in username on Gentoo, it isn't on Fedora and it isn't on Ubuntu, and I won't waste more time checking others... Besides, common sense suggests more than a bunch of pretty obvious reasons why it isn't a valid character.

Nothing to fix here beyond your broken usernames, closing.
Comment 10 Enrico 'nekrad' Weigelt 2006-09-14 16:59:16 UTC
(In reply to comment #8)

> You keep insisting that a Gentoo-provided patch results in this behaviour (the
> disallowing of '\' in a login name); please either show us this patch, or shut up.  

It breaks on '/' not '\'. 

See:
openssh_4.3_p2.selinux.patch:54
openssh_4.3_p2.selinux.patch:85

> And I'm pretty sure you won't be able to as no patches are applied to
> sys-apps/shadow that explicitly disallow this.  Therefore, this is 
> an upstream problem - go pester them.

I'm not interested in shadown, but openssh at this point.


Comment 11 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 17:01:51 UTC
Damn read the code above! It's NOT a legal character, \ isn't and / isn't, [a-z_][a-z0-9_-]*[$] is.

Stop bugspamming us.
Comment 12 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 17:03:16 UTC
Closed.
Comment 13 Enrico 'nekrad' Weigelt 2006-09-14 17:39:09 UTC
WHO defines what's a legal username for openssh ? 

The openssh upstream does _NOT_ forbid it. 
As I already pointed out, it is the gentoo patch, which introduces the fault.
I'm still awaiting an good explaination, why gentoo breaks with the upstream here.

Comment 14 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 17:43:35 UTC
There's nothing broken here except for your usernames. There's no way to create such broken usernames except for using a homebrew broken useradd. If you are using broken homebrew useradd to create broken invalid usernames, then go "fix" openssh to honor such invalid usernames yourself, as you did with useradd. 

It's non-issue for anyone using valid usernames, nothing to be fixed here.
Comment 15 Enrico 'nekrad' Weigelt 2006-09-14 17:55:07 UTC
We're talking about sshd, not useradd. 

Maybe useadd refuses slashes, but why then should openssh explicitly break with them ? 
_ALL_ other tools work properly with slashes in usernames, and you *still* did not tell me any reason, why it should be forbidden.

Gentoo always claims to be as near to the upstream as possible. The vanilla openssh does not break with slashes - this behaviour is explicitly introduced by gentoo. Why ?!
Comment 16 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 17:56:25 UTC
Sure, just that openssh authenticates against user accounts, which are broken on your box because they contain illegal characters.
Comment 17 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 17:57:36 UTC
CLOSED, stop reopening this bug. We won't support your broken useradd that's not distributed by us.
Comment 18 Enrico 'nekrad' Weigelt 2006-09-14 18:01:29 UTC
WHO defines what's a legal username for openssh ? 

The openssh upstream does _NOT_ forbid it. 
As I already pointed out, it is the gentoo patch, which introduces the fault.
I'm still awaiting an good explaination, why gentoo breaks with the upstream here.
Comment 19 Enrico 'nekrad' Weigelt 2006-09-14 18:04:53 UTC
Created attachment 97019 [details, diff]
fixed version of openssh-4.3_p2-selinux.patch

simply removed the explicit cutting of the username on / in auth1.c and auth2.c
Comment 20 Jakub Moc (RETIRED) gentoo-dev 2006-09-14 18:07:23 UTC
Feel free to remove it in your overlay. If you still didn't grok that openssh uses system accounts to verify users and that your accounts are not valid, there's no hope for you, sorry. 
Comment 21 Enrico 'nekrad' Weigelt 2006-09-14 20:06:46 UTC
Obviously there's no interest @ gentoo in fixing this. 
Interesting, that there's only *one* person always declaring this issue invalid and argumenting with an some completely different package, which has absolutely nothing to do with openssh. The other one, asking for an patch, got it.

So I'm going back to the upstream. It is working properly, as it already did for years.

@ Jakub: 
If you're too ignorant to event listen to my concern, also ignore the fact that it's the gentoo patch, which explicitly introduces this breakage, and just answer with invalid arguments instead explaining the NEED for that hard intervention (again: this is NOT done by the upstream !), then just become happy with your arrogance.

I don't intend to bother you anlonger. Someone who's not even willing to listen, isn't worth spending any further minute with.

My part is done. I supplied an patch, so others, having the same problem, can find it. 


Comment 22 Stephen Bennett (RETIRED) gentoo-dev 2006-09-15 02:16:41 UTC
Perhaps you would have more success if you provided a fixed patch which did not remove the feature that the patch was supposed to add in the first place.
Comment 23 Enrico 'nekrad' Weigelt 2006-09-15 03:26:09 UTC
Jabkub, why the hell are you deleting my patches ?!

I suspect, if you could, you probably would also delete my comments, since evrything I say is, per definition, invalid.
Comment 24 Enrico 'nekrad' Weigelt 2006-09-15 03:28:22 UTC
(In reply to comment #22)
> Perhaps you would have more success if you provided a fixed patch which did not
> remove the feature that the patch was supposed to add in the first place.

Aehm, what feature ? 
Destroying unliked usernames is an feature ? Why ?

Comment 25 Simon Stelling (RETIRED) gentoo-dev 2006-09-15 03:50:16 UTC
(In reply to comment #23)
> Jabkub, why the hell are you deleting my patches ?!
> 
> I suspect, if you could, you probably would also delete my comments, since
> evrything I say is, per definition, invalid.

He didn't delete it. It's still accessable. He just marked it obsolete because breaking another functionality is not acceptable. Nothing wrong with that, really.
Comment 26 Jakub Moc (RETIRED) gentoo-dev 2006-09-15 06:46:45 UTC
You broke selinux with your "fix". Do some research before messing with selinux stuff, in particular with user/role things.
Comment 27 Enrico 'nekrad' Weigelt 2006-09-15 11:25:16 UTC
(In reply to comment #26)
> You broke selinux with your "fix". Do some research before messing with selinux
> stuff, in particular with user/role things.
> 

Exactly ? 
Comment 28 Jakub Moc (RETIRED) gentoo-dev 2006-09-16 03:45:45 UTC
(In reply to comment #27)
> Exactly ? 

Exactly don't blindly delete parts of patches that are there for a reason.
Comment 29 Jakub Moc (RETIRED) gentoo-dev 2006-09-27 02:36:15 UTC
I'd just let this bug dead and burried, but since you are claiming that Gentoo developers are stupid (http://oss-qm.metux.de/index.php/Comment/nekrad/Stupid_gentoo_folks) I can't resist. 

Dear Enrico, kindly review IEEE Std 1003.1-2001 (Single UNIX Specification V3) - http://www.unix.org/single_unix_specification/

<quote>
 3.426 User Name

A string that is used to identify a user; see also User Database. To be portable across systems conforming to IEEE Std 1003.1-2001, the value is composed of characters from the portable filename character set. The hyphen should not be used as the first character of a portable user name.

 3.276 Portable Filename Character Set

The set of characters from which portable filenames are constructed.

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    0 1 2 3 4 5 6 7 8 9 . _ -

The last three characters are the period, underscore, and hyphen characters, respectively.
</quote>

So, before you start to rant next time, I'd suggest doing some legwork and research instead of publically claiming that someone is stupid; otherwise you risk making an idiot out of yourself. :P
Comment 30 Simon Stelling (RETIRED) gentoo-dev 2006-09-27 02:47:21 UTC
(In reply to comment #29)
> otherwise you
> risk making an idiot out of yourself. :P

Be realistic, there's not much to loose. 

Comment 31 Stephen Bennett (RETIRED) gentoo-dev 2006-09-27 09:21:12 UTC
The other thing you seem to be missing here is that the patch does not break at / merely because it can, but does so in order to add functionality that some users require, without breaking compliance with any known standards for valid usernames. That, not any sort of stubbornness, is the reason why the behaviour is not going to change.
Comment 32 Enrico 'nekrad' Weigelt 2006-09-27 10:24:27 UTC
(In reply to comment #29)
> I'd just let this bug dead and burried, but since you are claiming that Gentoo
> developers are stupid
> (http://oss-qm.metux.de/index.php/Comment/nekrad/Stupid_gentoo_folks) I can't
> resist. 

Ah, it worked. 
Seems, you just need some provocation as motivation ? ;-o

> Dear Enrico, kindly review IEEE Std 1003.1-2001 (Single UNIX Specification V3)
> - http://www.unix.org/single_unix_specification/

<snip>

Okay, it does not explicitly allow an / in usernames - if the username shall be portable. 
But I couldn't find anything that *forbids* the / - it's just not portable (as conforming to the standard).

BTW: at least on Linux, filenames *may* contain slashes (as well as spaces, etc). Just checked that. Of course they have to be escaped, if you want to access those files.

Still you didn't say, why it's necessary to cut off the username at an /.

As it is in the selinux patch, I just can assume, that is has something to do with selinux. But then, why isn't that code in some proper #ifdef ?


I really wonder why you just don't tell me the reason. Looks like you don't even know it.
Comment 33 Stephen Bennett (RETIRED) gentoo-dev 2006-09-27 10:33:36 UTC
Since, from my reading of the patch, the / is used to seperate user and role, the functionality is needed on any ssh client that is used to login to an selinux-enabled sshd. It makes no sense to wrap it in #ifdef.
Comment 34 Enrico 'nekrad' Weigelt 2006-09-27 10:39:28 UTC
(In reply to comment #31)
> The other thing you seem to be missing here is that the patch does not break at
> / merely because it can, but does so in order to add functionality that some
> users require, without breaking compliance with any known standards for valid  usernames. 

Maybe. But *WHAT* is this exactly for ? 
It's introduced by gentoo, not the upstream, and its done only in some versions.
There's no comment which tells what it is for. 

I only reason I could imagine is that selinux (ab)uses the / for somehing else, so its something selinux specific stuff. But why isn't it only built-in when selinux is really enabled ?
Comment 35 Enrico 'nekrad' Weigelt 2006-09-27 10:48:06 UTC
(In reply to comment #33)
> Since, from my reading of the patch, the / is used to seperate user and role,
> the functionality is needed on any ssh client that is used to login to an
> selinux-enabled sshd. It makes no sense to wrap it in #ifdef.

I think it makes sense if the sshd is _NOT_ selinux-enabled. 

When building w/ -selinux, why should there any selinux stuff ? Does this make sense ?

BTW: after deeper crawling in bgo, I learned that this patch probably was taken straight from Fedora. The changelog @ fedora looks interesting: turned selinux stuff on and off every few weeks ;-P
Comment 36 Jakub Moc (RETIRED) gentoo-dev 2006-09-27 10:49:57 UTC
I think that you miserably failed to provide a single valid reason for touching that patch, so unless you have one, stop producing noise on this bug. This is not a discussion forum.
Comment 37 Stephen Bennett (RETIRED) gentoo-dev 2006-09-27 11:02:58 UTC
> I think it makes sense if the sshd is _NOT_ selinux-enabled. 
> 
> When building w/ -selinux, why should there any selinux stuff ? Does this make
> sense ?

Read what I said. It's needed when logging in to a remote server whose sshd is selinux-enabled. This has nothing to do with the state of selinux on the local system.
Comment 38 Enrico 'nekrad' Weigelt 2006-09-27 11:18:25 UTC
I found some posting that indicates, the role is separated by an ":" (BSD also uses this for specificying some "style" - maybe something similar to roles).

http://www.nsa.gov/selinux/list-archive/0408/7999.cfm

The patch seems to differenciate between roles and styles. Styles are already supported by the upstream (probably BSD specific) - roles are introduced by the selinux patch.
What's the difference between styles and roles ?
Comment 39 Enrico 'nekrad' Weigelt 2006-09-27 12:50:16 UTC
Created attachment 98256 [details, diff]
openssh-4.3_p2-selinux-metux.patch

Fixed the selinux patch to be do the whole selinux stuff only if building w/ selinux is actually enabled. (#ifdef WITH_SELINUX ...)
Comment 40 Enrico 'nekrad' Weigelt 2006-09-27 12:51:30 UTC
Comment on attachment 98256 [details, diff]
openssh-4.3_p2-selinux-metux.patch

This patch may have better chances to go into the upstream.
Comment 41 Stephen Bennett (RETIRED) gentoo-dev 2006-09-27 13:15:25 UTC
That is a no go since it requires selinux to be enabled, and hence all the libraries installed, on the client machine in order to specify roles when logging in to an selinux-enabled server.
Comment 42 Jakub Moc (RETIRED) gentoo-dev 2006-09-27 13:22:39 UTC
I guess you really need to re-read Comment #33 and Comment #37 couple more times. There's no way for the client to know whether the remote sshd server has selinux enabled or not, this can't be conditional on selinux being enabled on client.
Comment 43 Enrico 'nekrad' Weigelt 2006-09-27 13:53:04 UTC
(In reply to comment #41)
> That is a no go since it requires selinux to be enabled, and hence all the
> libraries installed, on the client machine in order to specify roles when
> logging in to an selinux-enabled server.

Aehm, are we really talking about the same thing ? 

My changes are all in the _server_ code. Of course it's the _server_ who has to cope with selinux-specific stuff,

In a selinux-situation it's the server who has to split off the username string (passed by the client) into local username and role, so it can pass it to the proper selinux functions (and of course it needs the selinux libs for that ;-P).
But in an normal non-selinux situation, the whole stuff is really unnecessary.

I don't see where the client needs any of the selinux libs for logging into an selinux-box. (the client may not be even be an linux).


But, please correct me, if I'm wrong ...

Comment 44 Danny van Dyk (RETIRED) gentoo-dev 2006-09-27 13:54:44 UTC
Enrico: Please stop spamming this bug. As a displinary measure, i will disable
your account for one week.