#543 no posix:uid on windows (required by asdf)

closed-fixed
clisp (525)
5
2010-05-28
2010-02-26
No

asdf package requires uid symbol from posix, but its not exporting on win32 at all.
so, to load asdf on clisp from win32 now u have to do that:

(in-package #:posix)
(export '(uid))
(in-package #:cl-user)
(load "asdf\\asdf.lisp")

to fix it, u can just add #+win32 (export '(uid)) to the syscalls\\posix.lisp

Discussion

1 2 > >> (Page 1 of 2)
  • ander-skirnir

    ander-skirnir - 2010-02-26
    • summary: posix - win32 - bug --> posix - asdf - win32 - bug
     
  • Sam Steingold

    Sam Steingold - 2010-02-26

    how do we implement uid on windows?
    what's the windows analogue of getuid/geteuid/getgid &c?

     
  • Sam Steingold

    Sam Steingold - 2010-02-26
    • summary: posix - asdf - win32 - bug --> no posix:uid on windows (required by asdf)
     
  • ander-skirnir

    ander-skirnir - 2010-02-27

    quote from some forum: "You can access the Windows environment variable %USERNAME%. You didn't mention how you want to access it though. Batch file? Command Prompt? C/C++? With C/C++ you can use the getenv() function to retrieve specific environment variable values."

    useful discuss: http://stackoverflow.com/questions/1594746/win32-equivalent-of-getuid

     
  • Arseny Slobodyuk

    I believe on Windows, user's and group's UUID corresponds userid and groupid in UNIX. But UUID is a structure

    typedef struct _GUID
    {
    DWORD Data1;
    WORD Data2;
    WORD Data3;
    BYTE Data4[8];
    } GUID;

    which can be represented as string like {4208fb66-e22a-11d1-a7d7-00a0c982c00d}. This UUIDS however are unique - different on different computers.

    I dont know how it could help. Possibly "int getuid() {return 0;}" will do?

     
  • Sam Steingold

    Sam Steingold - 2010-03-01

    ander-skirnir: what is the original use case for this function? what is the expected contract?
    I don't think getenv is the right way here. I think OpenProcessToken+GetTokenInformation is the way to go.

    Arseny, I don't think string return value is a good idea - we should return a structure of 3 integers and a byte vector or maybe 5 integers.
    you can also provide a printer function which would produce the string you describe. Would you like to handle this issue? Thanks!

     
  • Sam Steingold

    Sam Steingold - 2010-03-01
    • assigned_to: haible --> ampy
     
  • Reini Urban

    Reini Urban - 2010-03-01

    I would prefer a simple
    #+win32 (defun uid () (getenv "USERNAME"))
    #+win32 (defun euid () (getenv "USERNAME"))

    and not using the GUID as arseny suggested.

    I don't know if the asdf uid is used as number, e.g. format, or used for numerical sorting.
    But asdf should add this patch, as one cannot force windows to return such a number,
    only a string. Windows is no posix, as everyone knows.

     
  • Sam Steingold

    Sam Steingold - 2010-03-01

    asdf uses getuid in resolve-relative-location-component as a pathname component.
    getenv is no good - it may return NIL which may screw sharing up.
    I think returning a struct based on OpenProcessToken+GetTokenInformation->UUID
    and defining a print-object method on it is the best approach.

     
  • Reini Urban

    Reini Urban - 2010-03-01

    I remember: The uid is used in asdf for site-location to discriminate the .fas cache for different users, which is not relevent for win32.
    If you are concerned about a deleted USERNAME env submit a uid patch to asdf, like
    #+win32 (defun uid () (or (getenv "USERNAME") ""))

     
  • Sam Steingold

    Sam Steingold - 2010-03-01

    even worse -- "" is not a valid pathname component.
    win32 _does_ support multiple users, so the issue _is_ relevant (and if it is not, asdf maintainers should handle that).

     
  • Arseny Slobodyuk

    Not that I like the idea, but, having conforming CL we could translate UUID to the large integer. Or (for the goal described here) get a hash from string of UUID or username. Using GetTokenInformation (thanks for the hint, Sam) will make CLISP dependent on yet another dll (its in the Advapi32.lib, getting USERNAME is much simpler), affecting load time and memory demands - is it acceptable? Which could be another uses of such a functions?

     
  • Arseny Slobodyuk

    Correcting myself: clisp/win32 is already depends on advapi32.

     
  • Arseny Slobodyuk

    I have investigated a little futher. Although Windows has posix compatibility layer (posix subsystem), there's seems no way to get integer userid, so, in fact the layer is incomplete. I dealt with, for example, Microsoft SFU (Services For Unix) - the mapping between users and uids, groups and uids (for NFS) is defined by administrator in the dedicated table. Same with Hummingbird NFS server. Is it a global trend to make Lisp C-posix-conforming? There will be difficulties, but I believe there's freedom in such a mapping and it could be done automatically.

     
  • Sam Steingold

    Sam Steingold - 2010-03-02

    the syscalls module is supposed to help in "systems programming".
    it should export all posix functions which do not have a better CL analogue.
    since there is no clear win32 analogue for unix uid, we are free to use uuids instead.
    I do not want to map the uuid struct to a bignum because this would prevent us from defining a print-object method.
    I still think that my suggestion in "2010-03-01 10:35" is correct: return a struct and define a print-object method.

     
  • Arseny Slobodyuk

    Sorry, I was wrong. User ID on Windows is not UUID but SID which is a variable-length structure (see http://msdn.microsoft.com/en-us/library/aa379597\(VS.85).aspx). We only can portably convert it to a sequence of bytes (integer) or to a string (like S-1-5-21-1645522239-1606980848-123456789-1234). The latter seems to me to have more use (can be used to do some registry hacking for example). I'm going to implement POSIX:GET-USER-SID -> string in syscalls.

     
  • Sam Steingold

    Sam Steingold - 2010-04-13

    the link you gave results in "Unable to Service Request".
    why don't you want to return a structure which will print as the right string?

     
  • Arseny Slobodyuk

    Don't know why you can't open the link - I'm opening it with no problem. Try search "SID Components" at msdn.microsoft.com or Google - the first result is the article.

    I don't want to create the structure because, although it's good for training in writing of CLISP modules:
    - I don't think its useful to have separate fields in the structure - for UUID there is no documentation on their meaning, for SID although there is an API to extract the (variable number of) fields - GetSidSubAuthority, but besides converting SID to a string it has only rather exotic applications AFAIK.
    - SID is like pathname or array not the structure (explained in the MSDN link).
    - This is intended way of its use, I believe. For example: to store user information in the registry, string representations of SIDs are used.

     
  • Sam Steingold

    Sam Steingold - 2010-04-27

    Arseny, thanks for adding GET-USER-SID.
    interestingly, on cygwin I see this:
    (string= (user-info-full-name (user-info :default)) (concatenate 'string "," (GET-USER-SID)))
    ==> T
    is this the officially documented cygwin behavior?

     
  • Sam Steingold

    Sam Steingold - 2010-04-27

    erm... this is not always the case, however, this holds:
    (dolist (u (user-info))
    (let* ((fn (user-info-full-name u))
    (sid (and (string/= "" fn) (get-user-sid (user-info-login-id u)))))
    (unless (or (null sid)
    (string= sid (subseq fn (1+ (position #\, fn :from-end t)))))
    (print (list u sid fn)))))
    can others comment on this observation?

     
  • Arseny Slobodyuk

    user-info is based on getpwent and gets info from /etc/passwd and I believe :FULL-NAME is constructed from various fields and results of system calls. It is like that it's treated as commenting field. The drawback of getpwent on cygwin is that /etc/passwd may be out of sync with system security state - for example, user can change his name in system and forget to update /etc/passwd, so (get-user-sid (user-info-login-id u)) will not succeed.

     
  • Arseny Slobodyuk

    Found at http://www.cygwin.com/cygwin-ug-net/ntsec.html :

    To use Windows security correctly, Cygwin depends on the files /etc/passwd and /etc/group. These files define the translation between the Cygwin uid/gid and the Windows SID. The SID is stored in the pw_gecos field in /etc/passwd, and in the gr_passwd field in /etc/group. Since the pw_gecos field can contain more information than just a SID, there are some rules for the layout. It's required that the SID is the last entry of the pw_gecos field, assuming that the entries in pw_gecos are comma-separated. The commands mkpasswd and mkgroup usually do this for you.

    Another interesting entry in the pw_gecos field (which is also usually created by running mkpasswd) is the Windows user name entry. It takes the form "U-domain\username" and is sometimes used by services to authenticate a user. Logging in through telnet is a common scenario.

     
  • Arseny Slobodyuk

    BTW, uid will return 400 (on cygwin) if the current user not listed in passwd.
    And (finally a bug!) - we should handle uid of -1 returned by getpwent - I have one such record on all machines I tried. Such a record is returnned for any user not listed in passwd and which is not current user. I couldn't guess who is it. It looks weird in lisp:
    [1]> (user-info)
    ( ...
    #<USER-INFO :LOGIN-ID "????????" :PASSWD "*" :UID 4294967295 :GID 4294967295 :FULL-NAME "" :HOME-DIR "" :SHELL "">)

    I'm afraid it leads us too far...

     
  • Sam Steingold

    Sam Steingold - 2010-04-28

    I confirm Arseny's observations about 400 & -1.
    however, getting back to the original issue:
    first of all, my understanding of asdf.lisp is that get-uid will not be defined on a windows machine without cygwin.
    this should take care of the original issue because on unix or cygwin clisp does define posix:uid.
    however, if it is desirable to implement get-uid on windows, one can use
    #+clisp (defun get-uid () #+win32 (os:get-user-sid) #-win32 (princ-to-string (posix:uid)))

     
  • Sam Steingold

    Sam Steingold - 2010-05-13

    This bug report is now marked as "pending"/"works for me".
    This means that we think that we cannot reproduce the problem
    and cannot do anything about it.
    Unless you - the reporter - act within 2 weeks
    (e.g., by submitting a self-contained test case
    or answering our other recent requests),
    the bug will be permanently closed.
    Sorry about the inconvenience -
    we hope your silence means that
    you are no longer observing the problem either.

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks