On 15/08/2010 22:12, Charles Wilson wrote:
> On 6/29/2009 2:53 PM, Andy Koppe wrote:
>> Shortcuts created by postinstall scripts using mkshortcut --allusers
>> --smprograms aren't readable for ordinary users, so all they get to
>> see in the start menu is a white dummy icon that doesn't do anything.
>> This affects both MinTTY and rxvt, at least with Cygwin 1.7 on Windows
>> 7. I guess the scripts could find out where the start menu is and
>> apply the necessary rights themselves, but it would make sense and be
>> much more convenient if mkshortcut did that.
> 
> Andy, if you'd like to roll this change into a forward-port of your
> other, wideAPI/locale patch, that'd be great.

This issue still seems to exist, and I couldn't find an actual patch to solve
it, so attached is an attempt at fixing this.
2011-04-21  Jon TURNEY  <jon.tur...@dronecode.org.uk>

        * src/mkshortcut/mkshortcut.c (mkshortcut): If we are
        creating shortcut for all users, ensure it is readable by
        all users.

Index: src/mkshortcut/mkshortcut.c
===================================================================
RCS file: /cvs/cygwin-apps/cygutils/src/mkshortcut/mkshortcut.c,v
retrieving revision 1.13
diff -u -r1.13 mkshortcut.c
--- src/mkshortcut/mkshortcut.c 18 Aug 2010 17:22:36 -0000      1.13
+++ src/mkshortcut/mkshortcut.c 21 Apr 2011 14:12:27 -0000
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <popt.h>
 */
+#include <sys/cygwin.h>
 
 static const char versionID[] = PACKAGE_VERSION;
 static const char revID[] =
@@ -611,6 +612,35 @@
             }
           persist_file->lpVtbl->Release (persist_file);
           shell_link->lpVtbl->Release (shell_link);
+
+          /* If we are creating shortcut for all users, ensure it is readable 
by all users */
+          if (opts.allusers_flag)
+            {
+              ssize_t size;
+              size = cygwin_conv_path(CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, 
widepath, NULL, 0);
+              if (size >= 0)
+                {
+                  char *posixpath = malloc(size);
+                  if (!cygwin_conv_path(CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, 
widepath, posixpath, size))
+                    {
+                      struct stat statbuf;
+                      if (stat(posixpath, &statbuf))
+                        {
+                          fprintf (stderr,
+                                   "%s: stat \"%s\" failed\n",
+                                   program_name, posixpath);
+                        }
+                      else if (chmod(posixpath, 
statbuf.st_mode|S_IRUSR|S_IRGRP|S_IROTH))
+                        {
+                          fprintf (stderr,
+                                   "%s: chmod \"%s\" failed\n",
+                                   program_name, posixpath);
+                        }
+                    }
+                  free(posixpath);
+                }
+            }
+
           return (0);
         }
       else
--
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

Reply via email to