Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Open Source

Review: Use Windows For Unix Services


The Posix subsystem for Windows has actually been around for quite some time. The technology used to be called Interix (and still is in some quarters), and was developed by a company called Softway Solutions for use with Windows NT. Microsoft acquired the company in the fall of 1999, and then combined Interix with some separate NFS and NIS technology into a retail add-on package called Services for Unix v2.0, also known as SFU. (I reviewed parts of SFU 2.0 for Network Computing magazine back in 2000, which you can read here.) Over the years since, the product has been further developed and enhanced to become SFU v3.0, and then SFU v3.5, becoming a free-for-download package along the way.

Microsoft is transitioning the product line again, integrating it directly into Windows, with the Posix component being renamed to Subsystem for Unix Applications (SUA). This transition actually started with Windows Server R2, but it's also the strategy going forward with Vista. The new labeling also signifies the fact that SUA is essentially a ground-up rewrite of the Posix environment--including 64-bit platform support, Open Database Connectivity (ODBC) interfaces, and better integration with Microsoft Visual Studio. But to user-space applications it's all still Interix.

The Posix subsystem essentially maps Windows resources to the Unix environment, providing an alternative "personality" for the Windows kernel through a Unix-like set of APIs and representations. For example, user accounts are not stored in a traditional /etc/passwd file, but instead are accessed through library calls like getpwnam and getpwuid, which the Posix subsystem then maps to the Windows authentication system via the legacy SAM database API.

This model allows the Windows authentication store to work somewhat seamlessly, regardless of whether the store itself is a local users and groups database, a legacy NT domain, or an Active Directory domain. The downside is that user account data is limited to what can be stored in the SAM database, which isn't much. Worse, the NIS server component of SFU provides Posix extensions for Active Directory, but those attributes cannot be used because the Posix subsystem can speak only to the SAM database API.

Likewise, the Posix file system is simply a representation of the underlying Windows file system, and can use only what Windows can provide. The root of the Unix file system is mapped to C:\SFU by default, although other parts of the Windows file system can be accessed through device aliases. (For instance, the root of the C: drive can be accessed via /dev/fs/C.)

Since there are no mount services to speak of, the only way to access remote file systems from the Posix subsystem is to set up a connection in Windows. For example, if you need to use a remote SMB share for a user's home directory, then you need to make sure the resource is mapped to a drive letter by Windows during the login process, either by the user's profile settings, or by using a login script. (This can be seen in the first screenshot above, which shows the user's home directory being mapped to Z:, or /dev/fs/Z in the Posix space.) This can be another point of weak integration in some cases. Because the user's home directory attribute gets used for the user's Posix home directory as well, you are stuck with UNC and drive letter paths for the SFU home directory, while remote systems can use NFS mount points and paths.

Windows and the Posix subsystem also share a common command environment, so you can call Windows executables from within a Unix shell simply by calling the executable like you would from any command prompt. The opposite works too--such as using "ls" to get a Unix-style directory listing from within the CMD command shell. But if you need the whole Posix subsystem--including file system mapping and the like—then you need to use the POSIX.EXE command as a front-end loader for the Unix-style command to create the full environment.

One area of disconnect here is in the background services: the Posix subsystem includes its own /etc/init.d startup scripts and cron scheduler, which are completely independent of the Windows service engine and Task Scheduler. Experimentation shows that it is possible to launch some of the Unix services as fake Windows services by using the "instsrv" utility from the Windows Resource Kit and "psxrun" (POSIX.EXE with the terminal I/O functions removed), although this is a crude hack at best. It would be nice if Microsoft could find a way to improve some of these mappings.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.