From d2d984ab6ee55b3f280284293dac6856fba202d5 Mon Sep 17 00:00:00 2001 From: Charles Wilson Date: Fri, 29 Apr 2011 03:59:41 +0000 Subject: [PATCH] Fix mkshortcut + AllUsers issue --- ChangeLog | 7 +++++++ src/mkshortcut/mkshortcut.c | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9083819..7bc2363 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-04-21 Jon TURNEY + Charles Wilson + + * src/mkshortcut/mkshortcut.c (mkshortcut): If we are + creating shortcut for all users, ensure it is readable by + all users. + 2011-04-28 Christian Franke * src/cygdrop/cygdrop.cc: Don't permute options. diff --git a/src/mkshortcut/mkshortcut.c b/src/mkshortcut/mkshortcut.c index 8d918de..2b06e4b 100644 --- a/src/mkshortcut/mkshortcut.c +++ b/src/mkshortcut/mkshortcut.c @@ -41,6 +41,7 @@ #include #include */ +#include static const char versionID[] = PACKAGE_VERSION; static const char revID[] = @@ -611,6 +612,31 @@ mkshortcut (optvals opts) } 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) + { + char *posixpath = (char *) cygwin_create_path ( + CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, widepath); + if (posixpath && *posixpath) + { + 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 -- 2.43.5