As I pick at details exposed by calls to getenv(), I found that there
are two distinct places that compute the name of the current user:
db_create_default_users() in db.c and user_select() in user.c. At first,
I was afraid these distinctions might be a source of conflict, but as I
write this, it appears they are frequently used together in a way such
that most of the fallback cases in user_select() would not apply.


db_create_default_users() can be passed a username. If provided it is
used. Otherwise, it checks the default-user setting, then in the
environment for $FOSSIL_USER, on Windows $USERNAME, or on other
platforms $USER then $LOGNAME. If none of those provided a name, it
defaults to "root". Called by "new", "clone", "import", and
"reconstruct". It only picked a user name, it did not "log in" to that user.

user_select() picks a user name, and logs in. It returns immediately if
a user is already logged in. If a username was provided (probably via
the global --user command line option), it will be logged in, and if
successful user_select() returns. Otherwise, it it tries in turn to log
in the user named in the local and global setting default-user, then
$FOSSIL_USER, $USER, $LOGNAME, $USERNAME, and finally a user named via
URL. Called by "new", "clone", and "reconstruct".


One difference is that user_select() does not restrict $USERNAME to
Windows only, or $USER and $LOGNAME to Unix only. As a result, if a
Windows user has $USER or $LOGNAME in their environment, it would block
$USERNAME in user_select() but not in db_create_default_users().

I'm hard pressed to see how that is exploitable for anything more than
brief (but puzzling) confusion. That said, it is a difference, and I
think that on Windows could cause a new repo to assign the name "root"
but then attempt to use a different name set in $USER or $LOGNAME for
the rest of the current command and future commands.


--
Ross Berteig                               r...@cheshireeng.com
Cheshire Engineering Corp.           http://www.CheshireEng.com/
+1 626 303 1602
_______________________________________________
fossil-dev mailing list
fossil-dev@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/fossil-dev

Reply via email to