Cygwin

From miki
Revision as of 00:35, 12 November 2008 by Mip (talk | contribs) (→‎Miscellaneous)
Jump to navigation Jump to search

Packages

Creating a local setup.ini

Packages in Cygwin can be installed from repositories. The content of these repositories is described in a file setup.ini. Each package in the repository is made of one or more .bz2 files (the actual package) and a file setup.hint (spec) describing the content of the package. The setup.ini file of the repository is actually a compilation of all setup.hint files in the repository along with additional information. Cygwin apparently does not want to install a package from a single .hint file (or at least have not found how to do so). In that case you need to generate the setup.ini file. Here's an example how this can be done.

Example is based on package recode v3.6.1.

  • Download the package above, and create following directory structure within Cygwin Local Package Directory (where setup.ini location is already shown).
.
|-- http%3a%2f%2fftp....
|   ...
`-- local
    |-- release
    |   `-- recode
    |       |-- recode-3.6-1-src.tar.bz2
    |       |-- recode-3.6-1.tar.bz2
    |       |-- recode-devel
    |       |   |-- recode-devel-3.6-1.tar.bz2
    |       |   `-- setup.hint
    |       `-- setup.hint
    `-- setup.ini
  • Create the file ./local/setup.ini with the following content:
# File manually generated on 20081105.
# setup-timestamp and setup-version are completely fake...
setup-timestamp: 1214338445
setup-version: 2.573.2.2

@ recode
sdesc: "GNU recode utility"
ldesc: "The program recognizes or produces approx. 150 character sets and can convert almost any character set to almost  any other."
category: text
requires: cygwin libintl3
version: 3.6-1
install: release/recode/recode-3.6-1.tar.bz2 838836 c185a17d8e1eb964611d26cbfe9b0e05
source: release/recode/recode-3.6-1-src.tar.bz2 1731299 83b0f5940aa5d2a82355586b6d977bab
  • (in gray) First the header
  • (in black) Then entry giving the package name
  • (in red) Then a copy-paste from setup.hint file.
  • (in green) Then the version (derived from package name)
  • (in blue) And finally two entries for binary and source package, giving for each: location of .bz2 file, the file size in bytes, the md5 checksum (as given by md5sum).

When done, simply install the package by running Cygwin setup.exe, asking to Install from Local Directory. Cygwin will see the new file setup.ini, and proposes for install the packages listed inside.

Troubleshooting

Cygwin

  • Look for multiple copies of the cygwin DLL cygwin1.dll. Removes all copies that are not in the cygwin install directory (usually c:\cygwin).
  • List of interfering software:
    • NoMachine NX Client - installs a custom version of the Cygwin DLL which can cause multiple interferences:
      • Cygwin crashes when multiple instances are launched.
      • Running cygwin commands (like ls) in a NT command shell when another instance of cygwin is running creates application error (Memory cannot be "read").
      • setup.exe fails because it runs several instances of bash.
    • SysInternals' Process Monitor
      • All back-quoted commands or $() commands in scripts fail until Windows is restarted

Missing DLL using strace

strace can be used to check whether an application needs a .DLL but cannot find it. This error is not reported by default on cygwin, so an application may just leave without any message, giving the impression that it simply does nothing. strace on the other hand will report about the missing .DLL. To solve the problem, install the .DLL somewhere in your PATH, or edit the PATH to include the .DLL location.

Example ([1]):

$ strace /usr/local/sbin/authtest                   # This will open a dialog box to complain about DLL.
$ export PATH=$PATH:/usr/local/lib/bin
$ /usr/local/sbin/authtest ausername

Adding Users

Create the user in Windows User Management first, then use command mkpasswd to add it to Cygwin environment.

$ net user <username> <password> /add /yes
$ net localgroup <an_local_group> <username> /add
$ mkpasswd -l -u <username> >> /etc/passwd

Installing a Service

Reference: Cygwin inetutils-1.5 OLD-README

Windows NT4, Windows 2000, Windows XP

Under Windows NT inetd must be started from service manager. To accompish that, you can install inetd as service running under cygrunsrv:

cygrunsrv -I inetd -d "CYGWIN inetd" -p /usr/sbin/inetd -a -D

This way, inetd is running as the SYSTEM (LocalSystem) user who has all required permissions, up to Windows XP.

There's also another way to install inetd as service. It allows to run inetd without cygrunsrv:

inetd --install-as-service
inetd --remove-as-service

However, this always installs inetd as service running under the SYSTEM account, with the problems mentioned below starting with Windows 2003. This also adds the problem that you have to change the system environment so that The Cygwin /bin directory is in %Path%. For that reason it's much better to use cygrunsrv to start inetd.

Windows 2003, Windows Vista

However, beginning with Windows 2003 Server and Windows Vista, the SYSTEM user is lacking the "Create a token object" right, which is required to change the user without providing the password.

On these systems you have to create an admin user account with special additional user rights. You can use the Cygwin tool editrights or the local/domain security policy mmc snap in to set these rights:

Create a token object
Act as part of the operating system
Replace process level token
Increase quotas
Logon as a service

Start/Stop the service

After you have installed inetd it will be started automatically on reboot. Manually starting and stopping is possible via

net start inetd
net stop inetd

Miscellaneous

  • Reference Cygwin documentation can be found in /usr/share/doc/cygwin-doc-1.4.
  • Interesting post about the 'su' command, explaining why there is no 'su' in Cygwin, and how 'ssh' overcomes this.
    • Other relevant post.
  • To make ins to paste text from clipboard, add to .inputrc:
"\e[2~": paste-from-clipboard
  • Use rxvt as terminal emulator instead of standard console window.

Cygwin Useful commands

id
Use command id to print user identity
getfacl
Display file and directory access control lists (ACLs).