[PATCH] Introduce the 'usertemp' filesystem type

2015-09-16 Thread Johannes Schindelin
* mount.cc (mount_info::from_fstab_line): support mounting the
current user's temp folder as /tmp/. This is particularly
useful a feature when Cygwin's own files are write-protected.

* pathnames.xml: document the new usertemp file system type

Detailed explanation:

In the context of Windows, there is a per-user directory for temporary
files, by default specified via the environment variable %TEMP%. Let's
allow to use that directory for our /tmp/ directory.

With this patch, we introduce the special filesystem type "usertemp":
By specifying

none /tmp usertemp binary,posix=0 0 0

in /etc/fstab, the /tmp/ directory gets auto-mounted to the directory
specified by the %TEMP% variable.

This feature comes handy in particularly in scenarios where the
administrator might want to write-protect the entire Cygwin directory
yet still needs to allow users to write into the /tmp/ directory.
This is the case in the context of Git for Windows, where the
Cygwin (MSys2) root directory lives inside C:\Program Files and hence
/tmp/ would not be writable otherwise.

Signed-off-by: Johannes Schindelin 
---
 winsup/cygwin/mount.cc   | 17 +
 winsup/doc/pathnames.xml | 24 +---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index 6cf3ddf..0b3dbdc 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -1139,6 +1139,8 @@ mount_info::from_fstab_line (char *line, bool user)
   unsigned mount_flags = MOUNT_SYSTEM | MOUNT_BINARY;
   if (!strcmp (fs_type, "cygdrive"))
 mount_flags |= MOUNT_NOPOSIX;
+  if (!strcmp (fs_type, "usertemp"))
+mount_flags |= MOUNT_IMMUTABLE;
   if (!fstab_read_flags (, mount_flags, false))
 return true;
   if (mount_flags & MOUNT_BIND)
@@ -1163,6 +1165,21 @@ mount_info::from_fstab_line (char *line, bool user)
   slashify (posix_path, cygdrive, 1);
   cygdrive_len = strlen (cygdrive);
 }
+  else if (!strcmp (fs_type, "usertemp"))
+{
+  WCHAR tmp[MAX_PATH];
+
+  if (GetEnvironmentVariableW (L"TEMP", tmp, sizeof(tmp)) && *tmp)
+   {
+  DWORD len;
+  char mb_tmp[len = sys_wcstombs (NULL, 0, tmp)];
+  sys_wcstombs (mb_tmp, len, tmp);
+
+ int res = mount_table->add_item (mb_tmp, posix_path, mount_flags);
+ if (res && get_errno () == EMFILE)
+   return false;
+   }
+}
   else
 {
   int res = mount_table->add_item (native_path, posix_path, mount_flags);
diff --git a/winsup/doc/pathnames.xml b/winsup/doc/pathnames.xml
index cdbf9fa..166c504 100644
--- a/winsup/doc/pathnames.xml
+++ b/winsup/doc/pathnames.xml
@@ -74,9 +74,10 @@ doesn't matter if you write FAT into this 
field even if
 the filesystem is NTFS.  Cygwin figures out the filesystem type and its
 capabilities by itself.
 
-The only exception is the file system type cygdrive.  This type is
-used to set the cygdrive prefix.  For a description of the cygdrive prefix
-see 
+The only two exceptions are the file system types cygdrive and usertemp.
+The cygdrive type is used to set the cygdrive prefix.  For a description of
+the cygdrive prefix see , for a description of
+the usertemp file system type see 
 
 The fourth field describes the mount options associated
 with the filesystem.  It is formatted as a comma separated list of
@@ -354,6 +355,23 @@ independently from the current cygdrive prefix:
 
 
 
+The usertemp file system type
+
+On Windows, the environment variable TEMP specifies
+the location of the temp folder.  It serves the same purpose as the /tmp/
+directory in Unix systems.  In contrast to /tmp/, it is by default a
+different folder for every Windows.  By using the special purpose usertemp
+file system, that temp folder can be mapped to /tmp/.  This is particularly
+useful in setups where the administrator wants to write-protect the entire
+Cygwin directory.  The usertemp file system can be configured in /etc/fstab
+like this:
+
+
+  none /tmp usertemp binary,posix=0 0 0
+
+
+
+
 Symbolic links
 
 Symbolic links are not present and supported on Windows until Windows
-- 
2.5.2.windows.2




[PATCH] Allow overriding the home directory via the HOME variable

2015-09-16 Thread Johannes Schindelin
* uinfo.cc (cygheap_pwdgrp::get_home): Offer an option in
nsswitch.conf that let's the environment variable HOME (or
HOMEDRIVE & HOMEPATH, or USERPROFILE) define the home
directory.

* ntsec.xml: Document the `env` schema.

Detailed comments:

In the context of Git for Windows, it is a well-established technique
to let the `$HOME` variable define where the current user's home
directory is, falling back to `$HOMEDRIVE$HOMEPATH` and `$USERPROFILE`.

The idea is that we want to share user-specific settings between
programs, whether they be Cygwin, MSys2 or not.  Unfortunately, we
cannot blindly activate the "db_home: windows" setting because in some
setups, the user's home directory is set to a hidden directory via an
UNC path (\\share\some\hidden\folder$) -- something many programs
cannot handle correctly.

The established technique is to allow setting the user's home directory
via the environment variables mentioned above.  This has the additional
advantage that it is much faster than querying the Windows user database.

Of course this scheme needs to be opt-in.  For that reason, it needs
to be activated explicitly via `db_home: env` in `/etc/nsswitch.conf`.

Signed-off-by: Johannes Schindelin 
---
 winsup/cygwin/cygheap.h |  3 ++-
 winsup/cygwin/uinfo.cc  | 47 +++
 winsup/doc/ntsec.xml| 20 
 3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index fd84814..097d50f 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -414,7 +414,8 @@ public:
 NSS_SCHEME_UNIX,
 NSS_SCHEME_DESC,
 NSS_SCHEME_PATH,
-NSS_SCHEME_FREEATTR
+NSS_SCHEME_FREEATTR,
+NSS_SCHEME_ENV
   };
   struct nss_scheme_t {
 nss_scheme_method  method;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index da5809f..c74954a 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -780,6 +780,8 @@ cygheap_pwdgrp::nss_init_line (const char *line)
scheme[idx].method = NSS_SCHEME_UNIX;
  else if (NSS_CMP ("desc"))
scheme[idx].method = NSS_SCHEME_DESC;
+ else if (NSS_CMP ("env"))
+   scheme[idx].method = NSS_SCHEME_ENV;
  else if (NSS_NCMP ("/"))
{
  const char *e = c + strcspn (c, " \t");
@@ -970,6 +972,40 @@ fetch_from_path (cyg_ldap *pldap, PUSER_INFO_3 ui, cygpsid 
, PCWSTR str,
   return ret;
 }
 
+static size_t
+fetch_env(LPCWSTR key, char *buf, size_t size)
+{
+  WCHAR wbuf[32767];
+  DWORD max = sizeof wbuf / sizeof *wbuf;
+  DWORD len = GetEnvironmentVariableW (key, wbuf, max);
+
+  if (!len || len >= max)
+return 0;
+
+  len = sys_wcstombs (buf, size, wbuf);
+  return len && len < size ? len : 0;
+}
+
+static char *
+fetch_home_env (void)
+{
+  char home[32767];
+  size_t max = sizeof home / sizeof *home, len;
+
+  if (fetch_env (L"HOME", home, max)
+  || ((len = fetch_env (L"HOMEDRIVE", home, max))
+&& fetch_env (L"HOMEPATH", home + len, max - len))
+  || fetch_env (L"USERPROFILE", home, max))
+{
+  tmp_pathbuf tp;
+  cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE,
+ home, tp.c_get(), NT_MAX_PATH);
+  return strdup(tp.c_get());
+}
+
+  return NULL;
+}
+
 char *
 cygheap_pwdgrp::get_home (cyg_ldap *pldap, cygpsid , PCWSTR dom,
  PCWSTR dnsdomain, PCWSTR name, bool full_qualified)
@@ -1029,6 +1065,9 @@ cygheap_pwdgrp::get_home (cyg_ldap *pldap, cygpsid , 
PCWSTR dom,
}
}
  break;
+   case NSS_SCHEME_ENV:
+ home = fetch_home_env ();
+ break;
}
 }
   return home;
@@ -1060,6 +1099,9 @@ cygheap_pwdgrp::get_home (PUSER_INFO_3 ui, cygpsid , 
PCWSTR dom,
  home = fetch_from_path (NULL, ui, sid, home_scheme[idx].attrib,
  dom, NULL, name, full_qualified);
  break;
+   case NSS_SCHEME_ENV:
+ home = fetch_home_env ();
+ break;
}
 }
   return home;
@@ -1079,6 +1121,7 @@ cygheap_pwdgrp::get_shell (cyg_ldap *pldap, cygpsid , 
PCWSTR dom,
case NSS_SCHEME_FALLBACK:
  return NULL;
case NSS_SCHEME_WINDOWS:
+   case NSS_SCHEME_ENV:
  break;
case NSS_SCHEME_CYGWIN:
  if (pldap->fetch_ad_account (sid, false, dnsdomain))
@@ -1143,6 +1186,7 @@ cygheap_pwdgrp::get_shell (PUSER_INFO_3 ui, cygpsid , 
PCWSTR dom,
case NSS_SCHEME_CYGWIN:
case NSS_SCHEME_UNIX:
case NSS_SCHEME_FREEATTR:
+   case NSS_SCHEME_ENV:
  break;
case NSS_SCHEME_DESC:
  shell = fetch_from_description (ui->usri3_comment, L"shell=\"", 7);
@@ -1223,6 +1267,8 @@ cygheap_pwdgrp::get_gecos (cyg_ldap *pldap, cygpsid , 
PCWSTR dom,
sys_wcstombs_alloc (, HEAP_NOTHEAP, 

Re: Error accessing mapped drive >2TB?

2015-09-16 Thread Nem W Schlecht
On Tue, Sep 15, 2015 at 6:21 PM, Warren Young  wrote:
> On Sep 15, 2015, at 9:14 AM, Nem W Schlecht  wrote:
>>
>> I'm going to be spinning up an Ubuntu box in the next few days that
>> will have a 5TB drive in it as well, so I'll be able to test to see if
>> the source OS (and/or version of SMB server) makes a difference.
>
> Good.
>
> Please test by exporting the filesystem root, since exporting a folder makes 
> the problem go away here.  Maybe Cygwin’s UNC path parsing simply can’t cope 
> with a bare slash where it expected at least one folder name?

The filesystem I'm having troubles with on the mac side is
/Volumes/project and being mapped on Windows from \\hostname\project
(or accessed via UNC in Cygwin as //hostname/project) so I'm already
thinking its not an issue with the path.

I would think if it was an issue with Mac's SMB implementation, then
*Windows* would also have some sort of issues with it.  But it shows
up fine on Windows, I would assume it should show fine in Cygwin as
well.

-- 
Nem W Schlecht

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Unable to send e-Mail from crontab in Cygwin

2015-09-16 Thread Shantaraman,Karthik

Hi,
I have set up cygwin in my Windows Vista machine and have configured 
cron by running the cygrunsrv command.


I am trying to send an automated mail everyday with cron but it is not 
working out. Could you help me with this?


#Borrowed from anacron
SHELL=/bin/bash
PATH=/usr/sbin:/usr/bin
USER=karthik.tec...@gmail.com
MAILTO="karthik.tec...@gmail.com"
#End borrowed from anacron

15 10 * * * sendmail /USER=karthik.tec...@gmail.com 
"karthik.tec...@gmail.com" testmail



I have installed the ssmtp package also after i researched about this 
online.


But it says :

$ ssmtp-config
-bash: ssmtp-config: command not found

Thanks,
Karthik


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Missing 'Luxi Sans' font

2015-09-16 Thread David Stacey
Following a request earlier in the year, I rebuilt mscgen with freetype 
support. mscgen required a default font that was scalable, and as Cygwin 
had a fairly limited selection of scalable fonts back then, I opted for 
'Luxi Sans' from the 'font-bh-ttf' package.


In the recent font reorganisation, the package 'font-bh-ttf' was made 
obsolete, replaced by 'xorg-x11-fonts-Type1'. Now, 
'xorg-x11-fonts-Type1' doesn't provide 'Luxi Sans' - in fact, this font 
is no longer provided in Cygwin. Is this intentional? I'm guessing this 
might be because 'Luxi Sans' has a non-free licence - see [1].


If the user has the 'dejavu-fonts' package installed then 'fc-match 
"Luxi Sans"' will find 'DejaVu Sans', so at least mscgen will pick a 
sensible font by default. I'll rebuild mscgen to use 'DejaVu Sans' as 
the default font - hopefully I'll get round to this at the weekend.


Dave.

[1] - https://bugzilla.redhat.com/show_bug.cgi?id=317641



--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



x3270 post install script fails

2015-09-16 Thread David Stacey

The x3270 package performs the following in its post install script:

FONTDIR=/usr/share/fonts
ENCODINGSDIR=$FONTDIR/encodings
MKFONTDIR=/usr/bin/mkfontdir
$MKFONTDIR -e $ENCODINGSDIR $FONTDIR/misc

This fails because the directory '/usr/share/fonts/encodings' no longer 
exists. (The directory used to be provided by the 'font-encodings' 
package, which is now obsolete).


Probably the best way to resolve this is to add a 'mkdir -p 
${ENCODINGSDIR}' to the post install script, rather than just assume its 
existence - provided this 'encodings.dir' is still being read by the X 
server. Otherwise, use '/usr/share/X11/fonts/encodings' as the encodings 
directory.


Dave.



--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: x3270 post install script fails

2015-09-16 Thread Peter A. Castro

On Wed, 16 Sep 2015, David Stacey wrote:


Date: Wed, 16 Sep 2015 23:17:10 +0100
From: David Stacey
Subject: x3270 post install script fails


Greetings, David,


The x3270 package performs the following in its post install script:

   FONTDIR=/usr/share/fonts
   ENCODINGSDIR=$FONTDIR/encodings
   MKFONTDIR=/usr/bin/mkfontdir
   $MKFONTDIR -e $ENCODINGSDIR $FONTDIR/misc

This fails because the directory '/usr/share/fonts/encodings' no longer 
exists. (The directory used to be provided by the 'font-encodings' package, 
which is now obsolete).


If it's obsolete then there's no point in having mkfontdir try and use it. 
Or would a user purposely create it for their own supplemental font usage?


Probably the best way to resolve this is to add a 'mkdir -p ${ENCODINGSDIR}' 
to the post install script, rather than just assume its existence - provided 
this 'encodings.dir' is still being read by the X server. Otherwise, use 
'/usr/share/X11/fonts/encodings' as the encodings directory.


Or, perhaps it would be better to check for the encodings directory 
existance and only supply it to mkfontdir then.  I'll play with this a 
little.


Thanks for the report.


Dave.


--
--=> Peter A. Castro
Email: doctor at fruitbat dot org / Peter dot Castro at oracle dot com
"Cats are just autistic Dogs" -- Dr. Tony Attwood

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Error accessing mapped drive >2TB?

2015-09-16 Thread Warren Young
On Sep 16, 2015, at 7:39 AM, Nem W Schlecht  wrote:
> 
> I would think if it was an issue with Mac's SMB implementation, then
> *Windows* would also have some sort of issues with it.  But it shows
> up fine on Windows, I would assume it should show fine in Cygwin as
> well.

More than that: Cygwin doesn’t contain an SMB client.  (I mean, not at the 
cygwin1.dll level.)  It is just using what Windows gives it.

That’s why I’m grasping at straws like the path error in the strace output, 
since the only thing that makes sense to me is a problem in the way Cygwin is 
interpreting what it gets from Windows, rather than the SMB protocol peers 
doing the wrong thing.

I suppose it could be that Windows Explorer and cygwin1.dll are making 
different NT kernel syscalls, and that explains the problem.  Lacking a “real” 
strace on Windows, I’m not sure how to test that.  Maybe Process Monitor could 
do this?

  https://technet.microsoft.com/en-us/sysinternals/bb896645

There is also this, one of the Google results for “Windows strace”:

  http://www.drmemory.org/strace_for_windows.html
--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Following update to XWin or xorg-server: changed syntax to get a xterm terminal window

2015-09-16 Thread Paul
Michael DePaulo  gmail.com> writes:
|On Wed, Jun 10, 2015 at 7:28 AM, Fergus Daly
| frontier-science.co.uk> wrote:
|> For ages I used
|> XWin -nolock -nolisten local -multiwindow &
|> xterm -display localhost:0.0
|> to get a xterm terminal.
|> Following recent updates I get a fatal error: "Cannot establish any
|> listening sockets." In the past, updates to XWin have sometimes led
|> to similar difficulties, but I have always managed to iterate to a
|> new successful joint syntax
|> XWin 
|> xterm 
| By default, XWin 1.17 no longer listens on TCP sockets, only on unix
| domain sockets.
| https://www.cygwin.com/ml/cygwin-announce/2015-06/msg3.html
| However, "-nolisten local" disables unix domain sockets.,
| So to use unix domain sockets:
| XWin -nolock -multiwindow &
| xterm -display :0.0
| Or to keep using TCP sockets:
| XWin -nolock -nolisten local -listen tcp -multiwindow &
| xterm -display localhost:0.0

I found that I also had to rejig my ~/.startxwinrc.

   ~/.startxwinrc:
   ---
   xrdb -load $HOME/.Xresources
   xterm -display :0.0 # xterm &
   exec sleep infinity


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



xpdf zoom-in/out ("-"/"+") doesn't work after "z"/"w"

2015-09-16 Thread Paul
After I press "z" to fit the page to the window, or "w" to fit the page
width within the window, I'm finding that "-" & "+" is unresponsive.  I can
get it responding again by first pression "0" to zoom to 125%, but I really
hope that this is not necessary.  Is anyone else experiencing this?  I
didn't use xpdf on this computer before, and just loaded the package tonight.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/