From: "Kiên Nguyễn Quang" <kien.n.quang@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 57386@debbugs.gnu.org
Subject: bug#57386: 29.0.50; support make-symbolic-link without admin priviledge on Windows
Date: Thu, 25 Aug 2022 19:32:13 +0900 [thread overview]
Message-ID: <CAL7sU5iJMshZA+_Cqh4g+59oFU-n0QJ55MRzG9DfKVg78QFnLQ@mail.gmail.com> (raw)
In-Reply-To: <83wnaw3asz.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 1146 bytes --]
Oops. Here it is.
On Thu, Aug 25, 2022 at 6:57 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Kiên Nguyễn Quang <kien.n.quang@gmail.com>
> > Date: Thu, 25 Aug 2022 18:51:30 +0900
> > Cc: 57386@debbugs.gnu.org
> >
> > > When you call an API with a parameter that is invalid, you are risking
> > > an exception, depending on the API and the build (debug or not). This
> > > has various unpleasant consequences; in the worst case, the Emacs
> > > process could be terminated. As documented, the problem is limited to
> > > CRT functions, but our general policy is to avoid that even when using
> > > the Win32 APIs. And version check is a simple enough way of avoiding
> > > that, so I see no reason not to do it here.
> >
> > Okay, that makes sense. Although I think that's the problem of CRT APIs
> only, as API should never throw
> > exceptions, which is a foreign concept to ABI and requires an exact
> library match to handle correctly
> >
> > The new patch is attached.
>
> Thanks, but I think you sent a wrong patch?
>
--
Nguyen Quang Kien - グエン クアン キエン
Software Developer @ MSD
[-- Attachment #1.2: Type: text/html, Size: 1873 bytes --]
[-- Attachment #2: 0001-symlink-allow-w32-user-to-create-symlink-without-adm.patch --]
[-- Type: application/octet-stream, Size: 1538 bytes --]
From d108561e58a3a5117b259bf03cb790db1407e670 Mon Sep 17 00:00:00 2001
From: Kien Nguyen <kien.n.quang@gmail.com>
Date: Wed, 24 Aug 2022 23:19:35 +0900
Subject: [PATCH] symlink: allow w32 non-admin user to create symlink
* src/w32.c (symlink): allow w32 user to create symlink without admin privileged
---
src/w32.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/w32.c b/src/w32.c
index cbcfcdd4f..5e5ed980f 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -5992,12 +5992,17 @@ sys_umask (int mode)
#ifndef SYMBOLIC_LINK_FLAG_DIRECTORY
#define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1
#endif
+#ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+#define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x2
+#endif
int
symlink (char const *filename, char const *linkname)
{
char linkfn[MAX_UTF8_PATH], *tgtfn;
- DWORD flags = 0;
+ /* The new flag is supported from build 14972 */
+ DWORD flags = (w32_build_number >= 14972) ?
+ SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE : 0;
int dir_access, filename_ends_in_slash;
/* Diagnostics follows Posix as much as possible. */
@@ -6055,7 +6060,7 @@ symlink (char const *filename, char const *linkname)
directory. */
filename_ends_in_slash = IS_DIRECTORY_SEP (filename[strlen (filename) - 1]);
if (dir_access == 0 || filename_ends_in_slash)
- flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
+ flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
tgtfn = (char *)map_w32_filename (filename, NULL);
if (filename_ends_in_slash)
--
2.37.0.windows.1
next prev parent reply other threads:[~2022-08-25 10:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 15:33 bug#57386: 29.0.50; support make-symbolic-link without admin priviledge on Windows Kiên Nguyễn Quang
2022-08-24 16:00 ` Eli Zaretskii
2022-08-24 18:05 ` Kiên Nguyễn Quang
2022-08-24 18:26 ` Eli Zaretskii
2022-08-25 1:30 ` Kiên Nguyễn Quang
2022-08-25 5:50 ` Eli Zaretskii
2022-08-25 8:52 ` Kiên Nguyễn Quang
2022-08-25 9:09 ` Eli Zaretskii
2022-08-25 9:51 ` Kiên Nguyễn Quang
2022-08-25 9:57 ` Eli Zaretskii
2022-08-25 10:32 ` Kiên Nguyễn Quang [this message]
2022-08-25 13:22 ` Eli Zaretskii
2022-08-25 11:35 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-25 12:59 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAL7sU5iJMshZA+_Cqh4g+59oFU-n0QJ55MRzG9DfKVg78QFnLQ@mail.gmail.com \
--to=kien.n.quang@gmail.com \
--cc=57386@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).