Commit graph

34 commits

Author SHA1 Message Date
Andrew Schwartzmeyer
e64c8961c9 Update GetUserName tests
Note that these fail when run in a Docker container because a) the
current container's locale is not completely set, and b) getlogin()
returns null with ENOENT since /var/run/utmp is being mapped to the
host, and thus denied access from within the container.

The container needs the locale set and its own /run/utmp, see
https://lists.linuxcontainers.org/pipermail/lxc-users/2011-July/002374.html
2015-08-04 14:16:57 -07:00
Andrew Schwartzmeyer
d60bfe0376 Use icu for Unicode conversion and fix lpnSize
A careful reading of the GetUserName documentation and Windows Data
Types says that lpnSize is "the number of TCHARs copied to the
buffer...including the terminating null character," and a TCHAR in this
environment is a CHAR because we assume UNICODE is always defined for
CoreCLR. A CHAR is a byte. So lpSize is number of bytes, not number of
UTF-16 characters as we previously believed.
2015-08-04 14:16:49 -07:00
Andrew Schwartzmeyer
6ddb39e337 Link ps against icu instead of scxcore
Remove scxcore library from CMake
2015-08-04 14:14:07 -07:00
Andrew Schwartzmeyer
0c9fb0d01b Rename userName in test to expectedUsername
To clarify that it is for comparison; not the result of GetUserName.
2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
b076850012 Refactor setting of lpnSize when buffer size is insufficient 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
2a2c1d9236 Remove unnecessary static qualifier from const string 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
0592a37395 Use std::string instead of C99 dynamic array 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
9426e9c455 Use LOGIN_NAME_MAX instead of L_cuserid
Since L_cuserid is only for cuserid, not getlogin_r

Unit test for L_cuserid removed because the macro may not be available
on all platforms.
2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
cbee353d0d Add more unit test coverage for GetUserName 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
4a2c1c5a95 Set lpnSize when insufficient 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
0f07a65f50 Use test fixture in GetUserName unit tests 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
e8cb7e24fe Use L_cuserid instead of 64 and given lpnSize 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
3ab3408378 Factor out using directives 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
6699091f7b Change global to local static const
To avoid polluting the global namespace without using a namespace.
2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
41a00d9279 Clarify lpBuffer layout in GetUserName unit test 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
3ac74ab849 Convert get_login_r to UTF-16 and return 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
6481f0336d Check for invalid parameters in GetUserName 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
a18a5912ab Explain GetUserName signature 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
ff0b43015b Test UTF-16 output of GetUserName 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
8dbe788284 Link scxcore to ps and include headers 2015-08-03 13:00:34 -07:00
Andrew Schwartzmeyer
f8eedc7210 Add unit test for GetUserName 2015-08-03 12:58:59 -07:00
Andrew Schwartzmeyer
b80da9ab4d Use getlogin_r() in GetUserName and map errno 2015-08-03 12:53:39 -07:00
Andrew Schwartzmeyer
f676c77a8e Check locale in GetUserName 2015-08-03 12:53:39 -07:00
Andrew Schwartzmeyer
4404e03613 Update GetUserName signature 2015-08-03 12:53:39 -07:00
Peter Honeder
8eeb24ece9 added hostutil.h, added tests for hostutil, added more cmdline options to PS host 2015-07-30 16:53:35 +02:00
Peter Honeder
ff2ceeceb7 added interpreting the verbose option 2015-07-29 18:12:31 +02:00
Peter Honeder
ea76b7e8fd fixed string termination issue, added verbose mode 2015-07-28 18:49:32 +02:00
Peter Honeder
c0414f8fc4 cleaned up implementation, added command line parsing and standardized managed interface for cmdline hosts 2015-07-28 18:28:09 +02:00
Peter Honeder
ba45c8f076 renamed function pointer type, changed code to call UnmanagedMain 2015-07-27 18:40:33 +02:00
Peter Honeder
b9784906f4 added first version of custom PS hosting code 2015-07-27 17:40:14 +02:00
Peter Honeder
39e939ce0f added pinvoke functions to query terminal size 2015-07-07 18:04:23 -07:00
Peter Honeder
1b02619b2d added libps.so, added stub for GetUserName 2015-06-16 14:02:19 -07:00
Pete Baker
0c5f78a223 built and tested - pass 2015-03-19 13:09:36 -07:00
Peter Honeder
beb5be9ffa initial commit 2015-03-05 14:58:25 -08:00