diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 298b9d658..78eaa118f 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,12 @@ +2004-03-30 Joshua Daniel Franklin + + * ntsec.sgml: Replace chapter numbers with s, + replace release-numbers in s with descriptions. + +2004-03-30 Ronald Landheer-Cieslak <ronald@landheer.com> + + * ntsec.sgml: Fix typos, correct chapter numbers. + 2004-03-29 Corinna Vinschen <corinna@vinschen.de> * pathnames.sgml: Fix /dev/srX description. diff --git a/winsup/doc/ntsec.sgml b/winsup/doc/ntsec.sgml index 9cbd0bb06..c9421fd23 100644 --- a/winsup/doc/ntsec.sgml +++ b/winsup/doc/ntsec.sgml @@ -1,23 +1,43 @@ -<sect1 id="ntsec"><title>NT security and the <literal>ntsec</literal> usage +NT security and usage of <literal>ntsec</literal> -The design goal of ntsec is to get a more UNIX like +The setting of UNIX like object permissions is controlled by the +CYGWIN environment +variable setting (no)ntsec which is set to +ntsec by default. + +The design goal of ntsec is to get a more UNIX-like permission structure based upon the security features of Windows NT. -To describe the changes, I will give a short overview of NT security -in chapter one. -Chapter two discusses the changes in ntsec related to privileges on -processes. -Chapter three shows the basics of UNIX like setting of -file permissions. -Chapter four talks about the advanced settings introduced in -release 1.1 -Chapter five illustrates the permission mapping leak of Windows NT. -Chapter six describes the new support of a setuid concept introduced -with release 1.1.3. +To describe the changes, I will first give a short overview in +. + + +discusses the changes in ntsec related to privileges on processes. -Chapter six describes in short the new acl API since release 1.1 + shows +the basics of UNIX-like setting of file permissions. -The setting of UNIX like object permissions is controlled by the new -CYGWIN variable setting (no)ntsec. + +talks about using SIDs in /etc/passwd and +/etc/group. + + +illustrates the permission mapping leak of Windows NT. + + +describes in short the ACL API since release 1.1. + + +describes the new support of a setuid concept introduced with release +1.1.3. + + +gives the basics of using the SYSTEM user to switch user context. + + + +explains the way Cygwin shows users and groups that are not in +/etc/passwd or /etc/group. + NT security @@ -54,7 +74,7 @@ identifies the source that issued the SID. While each system in a NT network has it's own SID, the situation is modified in NT domains: The SID of the domain controller is the base SID for each domain user. If an NT user has one account as domain -user and another account on his local machine, this accounts are under +user and another account on his local machine, these accounts are under any circumstances DIFFERENT, regardless of the usage of the same user name and password! @@ -71,15 +91,15 @@ name and password! The last part of the SID, the so called `relative identifier' (RID), -is by default used as UID and/or GID under cygwin. As the name and the +is by default used as UID and/or GID under Cygwin. As the name and the above example implies, this id is unique only relative to one system or domain. -Note, that it's possible, that an user has the same RID on two +Note, that it's possible that a user has the same RID on two different systems. The resulting SIDs are nevertheless different, so the SIDs are representing different users in an NT network. -There is a big difference between UNIX IDs and NT SIDs, the existence of +There is a big difference between UNIX IDs and NT SIDs: the existence of the so called `well known groups'. For example UNIX has no GID for the group of `all users'. NT has an SID for them, called `Everyone' in the English versions. The SIDs of well-known groups are not unique across @@ -128,6 +148,7 @@ has a potentially infinite number of members. Every member is a so called set + The two important types of ACEs are the `access allowed ACE' and the `access denied ACE'. The ntsec functionality only used `access allowed ACEs' up to Cygwin version 1.1.0. Later versions also use `access denied ACEs' @@ -144,7 +165,7 @@ system. The NT security model is MOSTLY able to reproduce the POSIX model. The ntsec method tries to do this in cygwin. You ask "Mostly? Why mostly???" Because there's a leak in the NT model. -I will describe that in detail in chapter 4. +I will describe that in detail in chapter 5. Creating explicit object security is not that easy so you will often see only two simple variations in use: @@ -163,9 +184,9 @@ this document the difference between SDs and SAs is ignored. -Process privileges +Process privileges -Any process started under control of cygwin has a semaphore attached +Any process started under control of Cygwin has a semaphore attached to it, that is used for signaling purposes. The creation of this semaphore can be found in sigproc.cc, function `getsem'. The first parameter to the function call `CreateSemaphore' is an SA. Without ntsec this SA @@ -181,18 +202,18 @@ administrators' group and for `system', which is a synonym for the operating system itself. The creation of this SA is done by the function `sec_user', that can be found in `shared.cc'. Each member of the administrators' group is now allowed to send signals to any process -created in cygwin, regardless of the process owner. +created in Cygwin, regardless of the process owner. Moreover, each process now has the appropriate security settings, when it is started via `CreateProcess'. You will find this in function `spawn_guts' in module `spawn.cc'. The security settings for starting a -process in another user context have to add the sid of the new user, too. +process in another user context have to add the SID of the new user, too. In the case of the `CreateProcessAsUser' call, sec_user creates an SA with an additional entry for the sid of the new user. -File permissions +File permissions If ntsec is turned on, file permissions are set as in UNIX. An SD is assigned to the file containing the owner and group and ACEs for the @@ -205,7 +226,7 @@ functions `read_sd' and `write_sd'. `write_sd' uses the function `BackupRead' instead of the simpler function `SetFileSecurity' because the latter is unable to set owners different from the caller. -If you are creating a file `foo' outside of cygwin, you will see something +If you are creating a file `foo' outside of Cygwin, you will see something like the following on ls -ln: If your login is member of the administrators' group: @@ -218,9 +239,9 @@ like the following on ls -ln: Note the user and group IDs. 544 is the UID of the administrators' group. -This is a `feature' :-P of WinNT. If one is a member of -the administrators' group, every file, that he has created is owned by the -administrators' group, instead by him. +This is a `feature' :-P of WinNT. If you are a member of +the administrators' group, every file that you create is owned by the +administrators' group, instead of by you. The second example shows the UID of the first user, that has been created with NT's the user administration tool. The users and groups are @@ -235,17 +256,17 @@ the group `None' is never shown in the user admin tool outside of domains! This is very confusing but this seems to have no negative consequences. To work correctly, ntsec depends on the files -/etc/passwd/ and /etc/group. -In cygwin release 1.0 the names and the IDs must correspond to the -appropriate NT IDs! The IDs used in cygwin are the RID of the NT SID, as +/etc/passwd and /etc/group. +In Cygwin release 1.0 the names and the IDs must correspond to the +appropriate NT IDs! The IDs used in Cygwin are the RID of the NT SID, as mentioned earlier. -An SID of e.g. the user `corinna' on my NT workstation: +A SID of e.g. the user `corinna' on my NT workstation: S-1-5-21-165875785-1005667432-441284377-1000 -Note the last number: It's the RID 1000, the cygwin's UID. +Note the last number: It's the RID 1000, Cygwin's UID. Unfortunately, workstations and servers outside of domains are not able to set primary groups! In these cases, where there is no correlation @@ -292,25 +313,26 @@ by the powerusers group instead of None. This is the way I liked it. Groups may be mentioned in the passwd file, too. This has two advantages: + Because NT assigns them to files as owners, a ls -l is often more readable. Moreover it's possible to assigned them to files as -owners with cygwin's chown. +owners with Cygwin's chown. The group `system' is the aforementioned synonym for the operating system -itself and is normally the owner of processes, that are started through -service manager. The same is true for files, that are created by +itself and is normally the owner of processes that are started through +service manager. The same is true for files that are created by processes, which are started through service manager. -New since Cygwin release 1.1 +NT SIDs in Cygwin In Cygwin release 1.1 a new technique of using the /etc/passwd and /etc/group - is introduced. + was introduced. Both files may now contain SIDs of users and groups. They are saved in the last field of pw_gecos in /etc/passwd @@ -320,9 +342,9 @@ and in the gr_passwd field in /etc/group. ntsec works better in domain environments. Accounts (users and groups) may get another name in -cygwin than their NT account name. The name in /etc/passwd -or /etc/group is transparently used by cygwin -applications (eg. chown, chmod, +Cygwin than their NT account name. The name in /etc/passwd +or /etc/group is transparently used by Cygwin +applications (e.g. chown, chmod, ls): @@ -378,10 +400,10 @@ the options -s or --no-sids. I suggest not to do this since ntsec works better when having the SIDs available. Please note that the pw_gecos field in /etc/passwd -is defined as a comma seperated list. The SID has to be the last field! +is defined as a comma separated list. The SID has to be the last field! -As aforementioned you are able to use cygwin account names different -from the NT account names. If you want to login thru `telnet' or something +As aforementioned you are able to use Cygwin account names different +from the NT account names. If you want to login through `telnet' or something else you have to use the special login. You may then add another field to pw_gecos which contains the NT user name including it's domain. So you are able to login as each domain user. The syntax @@ -441,13 +463,14 @@ users:S-1-5-32-545:545: If you want to do similar changes to your files, please do that only if you're feeling comfortably with the concepts. Otherwise don't be surprised if some stuff doesn't work anymore. If you screwed up things, revert to files -created by mkpasswd and mkgroup. Especially don't change the uid or the name +created by mkpasswd and mkgroup. Especially don't change the UID or the name of user SYSTEM. Even if that works mostly, some Cygwin applications running -as local service under that account could behave strangly suddenly. +as local service under that account could suddenly start behaving strangely. + -The mapping leak +The mapping leak Now its time to point out the leak in the NT permissions. The official documentation explains in short the following: @@ -463,7 +486,7 @@ access allowed ACE. Note that the last rule is a preference, not a law. NT will correctly deal with the ACL regardless of the sequence order. The second rule is -not modified to get the ACEs in the prefered order. +not modified to get the ACEs in the preferred order. Unfortunately the security tab of the NT4 explorer is completely unable to deal with access denied ACEs while the explorer of W2K rearranges @@ -509,7 +532,7 @@ OthersAllow: 110 Now the group may not write as intended but unfortunately the user may -not write anymore, too. How should this problem be solved? According to +not write anymore, either. How should this problem be solved? According to the official rules a UserAllow has to follow the GroupDeny but it's easy to see that this can never be solved that way. @@ -528,9 +551,9 @@ able to deal with that order. -New acl API +The ACL API -For dealing with ACLs Cygwin now has the acl API as it's +For dealing with ACLs Cygwin now has the ACL API as it's implemented in newer versions of Solaris. The new data structure for a single ACL entry (ACE in NT terminology) is defined in sys/acl.h as: @@ -544,7 +567,7 @@ typedef struct acl { The a_perm member of the aclent_t type contains only the bits -for read, write and execute as in the file mode. If eg. read permission +for read, write and execute as in the file mode. If e.g. read permission is granted, all read bits (S_IRUSR, S_IRGRP, S_IROTH) are set. CLASS_OBJ or MASK ACL entries are not fully implemented yet. @@ -563,12 +586,12 @@ acltotext(3), aclfromtext(3) ACLs on the command line: getfacl and setfacl. -Online man pages for the aforementioned commands and API calls -can be found on eg. http://docs.sun.com +Online man pages for the aforementioned commands and API calls can be +found on http://docs.sun.com -New setuid concept +New setuid concept UNIX applications which have to switch the user context are using the setuid and seteuid calls which @@ -577,7 +600,7 @@ Nevertheless these calls are supported under Windows NT/W2K since Cygwin release 1.1.3. Because of the nature of NT security an application which needs the ability has to be patched, though. -NT uses so called `access tokens' to identify a user and it's +NT uses so-called `access tokens' to identify a user and it's permissions. To switch the user context the application has to request such an `access token'. This is typically done by calling the NT API function LogonUser. The access token is returned and @@ -655,7 +678,7 @@ a short example: -The new Cygwin call to retrive an access token is defined as follows: +The new Cygwin call to retrieve an access token is defined as follows: #include <windows.h> @@ -666,7 +689,7 @@ cygwin_logon_user (struct passwd *pw, const char *cleartext_password) You can call that function as often as you want for different user -logons and remeber the access tokens for further calls to the second function. +logons and remember the access tokens for further calls to the second function. #include <windows.h> @@ -678,8 +701,8 @@ cygwin_set_impersonation_token (HANDLE hToken); is the call to inform Cygwin about the user context to which further calls to setuid/seteuid should switch to. -While you need always the correct access token to do a -setuid/seteuid to another users context, +While you always need the correct access token to do a +setuid/seteuid to another user's context, you are always able to use setuid/seteuid to return to your own user context by giving your own uid as parameter. @@ -710,7 +733,8 @@ etc. -New since Cygwin release 1.3.3 +Switching User +Context Since Cygwin release 1.3.3, applications having the @@ -723,7 +747,7 @@ the user context using e. g. rhosts authentication or (when running sshd under SYSTEM account as service) public key authentication. -An important restriction of this method is, that a process started under +An important restriction of this method is that a process started under SYSTEM account can't access network shares which require authentication. This also applies to the subprocesses which switched the user context without a password. People using network home drives are typically not @@ -732,7 +756,7 @@ able to access it when trying to login using ssh or rsh without password. -Special values of user and group +<sect2 id="ntsec-ids"><title id="ntsec-ids.title">Special values of user and group ids