unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57386: 29.0.50; support make-symbolic-link without admin priviledge on Windows
@ 2022-08-24 15:33 Kiên Nguyễn Quang
  2022-08-24 16:00 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Kiên Nguyễn Quang @ 2022-08-24 15:33 UTC (permalink / raw)
  To: 57386


[-- Attachment #1.1: Type: text/plain, Size: 190 bytes --]

The CreateSymbolicLink Win32API has a flag that allows creating sym-links
without admin privileges SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE.
This patch added that support for w32 Emacs.

[-- Attachment #1.2: Type: text/html, Size: 296 bytes --]

[-- Attachment #2: 0001-symlink-allow-w32-user-to-create-symlink-without-adm.patch --]
[-- Type: application/octet-stream, Size: 1451 bytes --]

From 4c5c2b942473c6737ec9f6ad0ee55583ee985875 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] allow w32 user to create symlink without admin privileged

* src/w32.c (symlink): allow w32 user to create symlink without admin privileged

---
 src/w32.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/w32.c b/src/w32.c
index cbcfcdd4f..23c0c8396 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -5992,12 +5992,15 @@ 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;
+  DWORD flags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
   int dir_access, filename_ends_in_slash;
 
   /* Diagnostics follows Posix as much as possible.  */
@@ -6055,7 +6058,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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-08-25 13:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).