implement missing wordexp functionality; patching lxqt-session fhs

This commit is contained in:
Symeon Huang 2021-05-21 10:37:58 +01:00 committed by Yaksh Bariya
parent 498032f9ea
commit 8038da6b63
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
11 changed files with 861 additions and 94 deletions

View File

@ -0,0 +1,262 @@
diff -uNr src/CMakeLists.txt src.mod/CMakeLists.txt
--- src/CMakeLists.txt 2021-05-21 08:58:40.268102000 +0000
+++ src.mod/CMakeLists.txt 2021-05-21 08:46:53.277571000 +0000
@@ -142,6 +142,8 @@
lxqtrotatedwidget.cpp
lxqtbacklight.cpp
lxqtbacklight/virtual_backend.cpp
+
+ wordexp.c
)
if (NOT APPLE)
diff -uNr src/wordexp.c src.mod/wordexp.c
--- src/wordexp.c 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/wordexp.c 2021-05-21 08:58:23.662102000 +0000
@@ -0,0 +1,184 @@
+// Copied from http://git.musl-libc.org/cgit/musl/plain/src/misc/wordexp.c
+// pthread-related lines are removed because they're missing on Android
+#include <wordexp.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+#include <fcntl.h>
+
+static void reap(pid_t pid)
+{
+ int status;
+ while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
+}
+
+static char *getword(FILE *f)
+{
+ char *s = 0;
+ return getdelim(&s, (size_t [1]){0}, 0, f) < 0 ? 0 : s;
+}
+
+static int do_wordexp(const char *s, wordexp_t *we, int flags)
+{
+ size_t i, l;
+ int sq=0, dq=0;
+ size_t np=0;
+ char *w, **tmp;
+ char *redir = (flags & WRDE_SHOWERR) ? "" : "2>/dev/null";
+ int err = 0;
+ FILE *f;
+ size_t wc = 0;
+ char **wv = 0;
+ int p[2];
+ pid_t pid;
+ sigset_t set;
+
+ if (flags & WRDE_REUSE) wordfree(we);
+
+ if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) {
+ case '\\':
+ if (!sq && !s[++i]) return WRDE_SYNTAX;
+ break;
+ case '\'':
+ if (!dq) sq^=1;
+ break;
+ case '"':
+ if (!sq) dq^=1;
+ break;
+ case '(':
+ if (np) {
+ np++;
+ break;
+ }
+ case ')':
+ if (np) {
+ np--;
+ break;
+ }
+ case '\n':
+ case '|':
+ case '&':
+ case ';':
+ case '<':
+ case '>':
+ case '{':
+ case '}':
+ if (!(sq|dq|np)) return WRDE_BADCHAR;
+ break;
+ case '$':
+ if (sq) break;
+ if (s[i+1]=='(' && s[i+2]=='(') {
+ i += 2;
+ np += 2;
+ break;
+ } else if (s[i+1] != '(') break;
+ case '`':
+ if (sq) break;
+ return WRDE_CMDSUB;
+ }
+
+ if (flags & WRDE_APPEND) {
+ wc = we->we_wordc;
+ wv = we->we_wordv;
+ }
+
+ i = wc;
+ if (flags & WRDE_DOOFFS) {
+ if (we->we_offs > SIZE_MAX/sizeof(void *)/4)
+ goto nospace;
+ i += we->we_offs;
+ } else {
+ we->we_offs = 0;
+ }
+
+ if (pipe2(p, O_CLOEXEC) < 0) goto nospace;
+ pid = fork();
+ if (pid < 0) {
+ close(p[0]);
+ close(p[1]);
+ goto nospace;
+ }
+ if (!pid) {
+ if (p[1] == 1) fcntl(1, F_SETFD, 0);
+ else dup2(p[1], 1);
+ execl("/bin/sh", "sh", "-c",
+ "eval \"printf %s\\\\\\\\0 x $1 $2\"",
+ "sh", s, redir, (char *)0);
+ _exit(1);
+ }
+ close(p[1]);
+
+ f = fdopen(p[0], "r");
+ if (!f) {
+ close(p[0]);
+ kill(pid, SIGKILL);
+ reap(pid);
+ goto nospace;
+ }
+
+ l = wv ? i+1 : 0;
+
+ free(getword(f));
+ if (feof(f)) {
+ fclose(f);
+ reap(pid);
+ return WRDE_SYNTAX;
+ }
+
+ while ((w = getword(f))) {
+ if (i+1 >= l) {
+ l += l/2+10;
+ tmp = realloc(wv, l*sizeof(char *));
+ if (!tmp) break;
+ wv = tmp;
+ }
+ wv[i++] = w;
+ wv[i] = 0;
+ }
+ if (!feof(f)) err = WRDE_NOSPACE;
+
+ fclose(f);
+ reap(pid);
+
+ if (!wv) wv = calloc(i+1, sizeof *wv);
+
+ we->we_wordv = wv;
+ we->we_wordc = i;
+
+ if (flags & WRDE_DOOFFS) {
+ if (wv) for (i=we->we_offs; i; i--)
+ we->we_wordv[i-1] = 0;
+ we->we_wordc -= we->we_offs;
+ }
+ return err;
+
+nospace:
+ if (!(flags & WRDE_APPEND)) {
+ we->we_wordc = 0;
+ we->we_wordv = 0;
+ }
+ return WRDE_NOSPACE;
+}
+
+int wordexp(const char *restrict s, wordexp_t *restrict we, int flags)
+{
+ int r, cs;
+ r = do_wordexp(s, we, flags);
+ return r;
+}
+
+void wordfree(wordexp_t *we)
+{
+ size_t i;
+ if (!we->we_wordv) return;
+ for (i=0; i<we->we_wordc; i++) free(we->we_wordv[we->we_offs+i]);
+ free(we->we_wordv);
+ we->we_wordv = 0;
+ we->we_wordc = 0;
+}
diff -uNr src/wordexp.h src.mod/wordexp.h
--- src/wordexp.h 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/wordexp.h 2021-05-21 08:58:53.085923000 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#ifndef _WORDEXP_H
+#define _WORDEXP_H 1
+#include <features.h>
+#define __need_size_t
+#include <stddef.h>
+__BEGIN_DECLS
+/* Bits set in the FLAGS argument to `wordexp'. */
+enum
+ {
+ WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
+ WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
+ WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
+ WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
+ WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
+ WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
+ __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
+ WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
+ };
+/* Structure describing a word-expansion run. */
+typedef struct
+ {
+ size_t we_wordc; /* Count of words matched. */
+ char **we_wordv; /* List of expanded words. */
+ size_t we_offs; /* Slots to reserve in `we_wordv'. */
+ } wordexp_t;
+/* Possible nonzero return values from `wordexp'. */
+enum
+ {
+#ifdef __USE_XOPEN
+ WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
+#endif
+ WRDE_NOSPACE = 1, /* Ran out of memory. */
+ WRDE_BADCHAR, /* A metachar appears in the wrong place. */
+ WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
+ WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
+ WRDE_SYNTAX /* Shell syntax error. */
+ };
+/* Do word expansion of WORDS into PWORDEXP. */
+extern int wordexp (__const char *__restrict __words,
+ wordexp_t *__restrict __pwordexp, int __flags);
+/* Free the storage allocated by a `wordexp' call. */
+extern void wordfree (wordexp_t *__wordexp);
+__END_DECLS
+#endif /* wordexp.h */

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="The core library of LXQt"
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="Simeon Huang <symeon@librehat.com>"
TERMUX_PKG_VERSION=0.17.0
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL="https://github.com/lxqt/liblxqt/releases/download/${TERMUX_PKG_VERSION}/liblxqt-${TERMUX_PKG_VERSION}.tar.xz"
TERMUX_PKG_SHA256=d44e3b4c0963537d5032328ac29bb0d61d454dc28d0fac7e1ddcb9d7be91c32b
TERMUX_PKG_DEPENDS="qt5-qtbase, qt5-qtx11extras, kwindowsystem, libqtxdg, libxss"

View File

@ -1,23 +0,0 @@
--- src/lxqtprogramfinder.cpp 2021-04-10 07:24:13.000000000 +0000
+++ src.mod/lxqtprogramfinder.cpp 2021-05-20 12:09:53.024301000 +0000
@@ -23,7 +23,6 @@
* END_COMMON_COPYRIGHT_HEADER */
#include "lxqtprogramfinder.h"
-#include <wordexp.h>
#include <QDir>
#include <QFileInfo>
@@ -62,11 +61,7 @@
return availPrograms;
}
-LXQT_API QString ProgramFinder::programName(const QString& command)
+LXQT_API QString ProgramFinder::programName(const QString& )
{
- wordexp_t we;
- if (wordexp(command.toLocal8Bit().constData(), &we, WRDE_NOCMD) == 0)
- if (we.we_wordc > 0)
- return QString::fromLocal8Bit(we.we_wordv[0]);
return QString();
}

View File

@ -0,0 +1,269 @@
diff -uNr src/CMakeLists.txt src.mod/CMakeLists.txt
--- src/CMakeLists.txt 2021-04-11 09:01:40.000000000 +0000
+++ src.mod/CMakeLists.txt 2021-05-21 09:09:57.339178000 +0000
@@ -71,6 +71,7 @@
providers.h
yamlparser.h
configuredialog/configuredialog.h
+ wordexp.h
)
set(lxqt-runner_CPP_FILES
@@ -81,6 +82,7 @@
providers.cpp
yamlparser.cpp
configuredialog/configuredialog.cpp
+ wordexp.c
)
set(lxqt-runner_UI_FILES
diff -uNr src/wordexp.c src.mod/wordexp.c
--- src/wordexp.c 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/wordexp.c 2021-05-21 09:10:10.115178000 +0000
@@ -0,0 +1,184 @@
+// Copied from http://git.musl-libc.org/cgit/musl/plain/src/misc/wordexp.c
+// pthread-related lines are removed because they're missing on Android
+#include <wordexp.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+#include <fcntl.h>
+
+static void reap(pid_t pid)
+{
+ int status;
+ while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
+}
+
+static char *getword(FILE *f)
+{
+ char *s = 0;
+ return getdelim(&s, (size_t [1]){0}, 0, f) < 0 ? 0 : s;
+}
+
+static int do_wordexp(const char *s, wordexp_t *we, int flags)
+{
+ size_t i, l;
+ int sq=0, dq=0;
+ size_t np=0;
+ char *w, **tmp;
+ char *redir = (flags & WRDE_SHOWERR) ? "" : "2>/dev/null";
+ int err = 0;
+ FILE *f;
+ size_t wc = 0;
+ char **wv = 0;
+ int p[2];
+ pid_t pid;
+ sigset_t set;
+
+ if (flags & WRDE_REUSE) wordfree(we);
+
+ if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) {
+ case '\\':
+ if (!sq && !s[++i]) return WRDE_SYNTAX;
+ break;
+ case '\'':
+ if (!dq) sq^=1;
+ break;
+ case '"':
+ if (!sq) dq^=1;
+ break;
+ case '(':
+ if (np) {
+ np++;
+ break;
+ }
+ case ')':
+ if (np) {
+ np--;
+ break;
+ }
+ case '\n':
+ case '|':
+ case '&':
+ case ';':
+ case '<':
+ case '>':
+ case '{':
+ case '}':
+ if (!(sq|dq|np)) return WRDE_BADCHAR;
+ break;
+ case '$':
+ if (sq) break;
+ if (s[i+1]=='(' && s[i+2]=='(') {
+ i += 2;
+ np += 2;
+ break;
+ } else if (s[i+1] != '(') break;
+ case '`':
+ if (sq) break;
+ return WRDE_CMDSUB;
+ }
+
+ if (flags & WRDE_APPEND) {
+ wc = we->we_wordc;
+ wv = we->we_wordv;
+ }
+
+ i = wc;
+ if (flags & WRDE_DOOFFS) {
+ if (we->we_offs > SIZE_MAX/sizeof(void *)/4)
+ goto nospace;
+ i += we->we_offs;
+ } else {
+ we->we_offs = 0;
+ }
+
+ if (pipe2(p, O_CLOEXEC) < 0) goto nospace;
+ pid = fork();
+ if (pid < 0) {
+ close(p[0]);
+ close(p[1]);
+ goto nospace;
+ }
+ if (!pid) {
+ if (p[1] == 1) fcntl(1, F_SETFD, 0);
+ else dup2(p[1], 1);
+ execl("/bin/sh", "sh", "-c",
+ "eval \"printf %s\\\\\\\\0 x $1 $2\"",
+ "sh", s, redir, (char *)0);
+ _exit(1);
+ }
+ close(p[1]);
+
+ f = fdopen(p[0], "r");
+ if (!f) {
+ close(p[0]);
+ kill(pid, SIGKILL);
+ reap(pid);
+ goto nospace;
+ }
+
+ l = wv ? i+1 : 0;
+
+ free(getword(f));
+ if (feof(f)) {
+ fclose(f);
+ reap(pid);
+ return WRDE_SYNTAX;
+ }
+
+ while ((w = getword(f))) {
+ if (i+1 >= l) {
+ l += l/2+10;
+ tmp = realloc(wv, l*sizeof(char *));
+ if (!tmp) break;
+ wv = tmp;
+ }
+ wv[i++] = w;
+ wv[i] = 0;
+ }
+ if (!feof(f)) err = WRDE_NOSPACE;
+
+ fclose(f);
+ reap(pid);
+
+ if (!wv) wv = calloc(i+1, sizeof *wv);
+
+ we->we_wordv = wv;
+ we->we_wordc = i;
+
+ if (flags & WRDE_DOOFFS) {
+ if (wv) for (i=we->we_offs; i; i--)
+ we->we_wordv[i-1] = 0;
+ we->we_wordc -= we->we_offs;
+ }
+ return err;
+
+nospace:
+ if (!(flags & WRDE_APPEND)) {
+ we->we_wordc = 0;
+ we->we_wordv = 0;
+ }
+ return WRDE_NOSPACE;
+}
+
+int wordexp(const char *restrict s, wordexp_t *restrict we, int flags)
+{
+ int r, cs;
+ r = do_wordexp(s, we, flags);
+ return r;
+}
+
+void wordfree(wordexp_t *we)
+{
+ size_t i;
+ if (!we->we_wordv) return;
+ for (i=0; i<we->we_wordc; i++) free(we->we_wordv[we->we_offs+i]);
+ free(we->we_wordv);
+ we->we_wordv = 0;
+ we->we_wordc = 0;
+}
diff -uNr src/wordexp.h src.mod/wordexp.h
--- src/wordexp.h 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/wordexp.h 2021-05-21 09:10:06.255178000 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#ifndef _WORDEXP_H
+#define _WORDEXP_H 1
+#include <features.h>
+#define __need_size_t
+#include <stddef.h>
+__BEGIN_DECLS
+/* Bits set in the FLAGS argument to `wordexp'. */
+enum
+ {
+ WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
+ WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
+ WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
+ WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
+ WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
+ WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
+ __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
+ WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
+ };
+/* Structure describing a word-expansion run. */
+typedef struct
+ {
+ size_t we_wordc; /* Count of words matched. */
+ char **we_wordv; /* List of expanded words. */
+ size_t we_offs; /* Slots to reserve in `we_wordv'. */
+ } wordexp_t;
+/* Possible nonzero return values from `wordexp'. */
+enum
+ {
+#ifdef __USE_XOPEN
+ WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
+#endif
+ WRDE_NOSPACE = 1, /* Ran out of memory. */
+ WRDE_BADCHAR, /* A metachar appears in the wrong place. */
+ WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
+ WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
+ WRDE_SYNTAX /* Shell syntax error. */
+ };
+/* Do word expansion of WORDS into PWORDEXP. */
+extern int wordexp (__const char *__restrict __words,
+ wordexp_t *__restrict __pwordexp, int __flags);
+/* Free the storage allocated by a `wordexp' call. */
+extern void wordfree (wordexp_t *__wordexp);
+__END_DECLS
+#endif /* wordexp.h */

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="LXQt application launcher"
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="Simeon Huang <symeon@librehat.com>"
TERMUX_PKG_VERSION=0.17.0
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL="https://github.com/lxqt/lxqt-runner/releases/download/${TERMUX_PKG_VERSION}/lxqt-runner-${TERMUX_PKG_VERSION}.tar.xz"
TERMUX_PKG_SHA256=24a68c50961e1157aabdb9a3899727f50012b77e401c15447c9bdc3af792a358
TERMUX_PKG_DEPENDS="qt5-qtbase, libqtxdg, kwindowsystem, liblxqt, lxqt-globalkeys"

View File

@ -1,36 +0,0 @@
--- src/providers.cpp 2021-04-11 09:01:40.000000000 +0000
+++ src.mod/providers.cpp 2021-05-20 16:11:17.052885000 +0000
@@ -48,7 +48,6 @@
#include <LXQt/ScreenSaver>
#include "providers.h"
#include <LXQtGlobalKeys/Action>
-#include <wordexp.h>
#include <QStandardPaths>
#define MAX_HISTORY 100
@@ -59,24 +58,7 @@
************************************************/
static QString expandCommand(const QString &command, QStringList *arguments=0)
{
- QString program;
- wordexp_t words;
-
- if (wordexp(command.toLocal8Bit().data(), &words, 0) != 0)
- return QString();
-
- char **w;
- w = words.we_wordv;
- program = QString::fromLocal8Bit(w[0]);
-
- if (arguments)
- {
- for (size_t i = 1; i < words.we_wordc; i++)
- *arguments << QString::fromLocal8Bit(w[i]);
- }
-
- wordfree(&words);
- return program;
+ return QString();
}

View File

@ -0,0 +1,274 @@
diff -uNr src/lxqt-session/CMakeLists.txt src.mod/lxqt-session/CMakeLists.txt
--- src/lxqt-session/CMakeLists.txt 2021-05-21 09:21:12.474337000 +0000
+++ src.mod/lxqt-session/CMakeLists.txt 2021-05-21 09:19:27.994338000 +0000
@@ -28,6 +28,8 @@
src/numlock.h
src/log.cpp
src/procreaper.cpp
+ src/wordexp.h
+ src/wordexp.c
)
if (WITH_LIBUDEV)
list(APPEND lxqt-session_SRCS src/UdevNotifier.cpp)
diff -uNr src/lxqt-session/src/lxqtmodman.cpp src.mod/lxqt-session/src/lxqtmodman.cpp
--- src/lxqt-session/src/lxqtmodman.cpp 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/lxqt-session/src/lxqtmodman.cpp 2021-05-21 09:21:32.128509000 +0000
@@ -43,7 +43,7 @@
#include <QDateTime>
#include "wmselectdialog.h"
#include "windowmanager.h"
-#include <wordexp.h>
+#include "wordexp.h"
#include "log.h"
#include <KWindowSystem/KWindowSystem>
diff -uNr src/lxqt-session/src/wordexp.c src.mod/lxqt-session/src/wordexp.c
--- src/lxqt-session/src/wordexp.c 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/lxqt-session/src/wordexp.c 2021-05-21 09:17:56.854283000 +0000
@@ -0,0 +1,184 @@
+// Copied from http://git.musl-libc.org/cgit/musl/plain/src/misc/wordexp.c
+// pthread-related lines are removed because they're missing on Android
+#include "wordexp.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+#include <fcntl.h>
+
+static void reap(pid_t pid)
+{
+ int status;
+ while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
+}
+
+static char *getword(FILE *f)
+{
+ char *s = 0;
+ return getdelim(&s, (size_t [1]){0}, 0, f) < 0 ? 0 : s;
+}
+
+static int do_wordexp(const char *s, wordexp_t *we, int flags)
+{
+ size_t i, l;
+ int sq=0, dq=0;
+ size_t np=0;
+ char *w, **tmp;
+ char *redir = (flags & WRDE_SHOWERR) ? "" : "2>/dev/null";
+ int err = 0;
+ FILE *f;
+ size_t wc = 0;
+ char **wv = 0;
+ int p[2];
+ pid_t pid;
+ sigset_t set;
+
+ if (flags & WRDE_REUSE) wordfree(we);
+
+ if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) {
+ case '\\':
+ if (!sq && !s[++i]) return WRDE_SYNTAX;
+ break;
+ case '\'':
+ if (!dq) sq^=1;
+ break;
+ case '"':
+ if (!sq) dq^=1;
+ break;
+ case '(':
+ if (np) {
+ np++;
+ break;
+ }
+ case ')':
+ if (np) {
+ np--;
+ break;
+ }
+ case '\n':
+ case '|':
+ case '&':
+ case ';':
+ case '<':
+ case '>':
+ case '{':
+ case '}':
+ if (!(sq|dq|np)) return WRDE_BADCHAR;
+ break;
+ case '$':
+ if (sq) break;
+ if (s[i+1]=='(' && s[i+2]=='(') {
+ i += 2;
+ np += 2;
+ break;
+ } else if (s[i+1] != '(') break;
+ case '`':
+ if (sq) break;
+ return WRDE_CMDSUB;
+ }
+
+ if (flags & WRDE_APPEND) {
+ wc = we->we_wordc;
+ wv = we->we_wordv;
+ }
+
+ i = wc;
+ if (flags & WRDE_DOOFFS) {
+ if (we->we_offs > SIZE_MAX/sizeof(void *)/4)
+ goto nospace;
+ i += we->we_offs;
+ } else {
+ we->we_offs = 0;
+ }
+
+ if (pipe2(p, O_CLOEXEC) < 0) goto nospace;
+ pid = fork();
+ if (pid < 0) {
+ close(p[0]);
+ close(p[1]);
+ goto nospace;
+ }
+ if (!pid) {
+ if (p[1] == 1) fcntl(1, F_SETFD, 0);
+ else dup2(p[1], 1);
+ execl("/bin/sh", "sh", "-c",
+ "eval \"printf %s\\\\\\\\0 x $1 $2\"",
+ "sh", s, redir, (char *)0);
+ _exit(1);
+ }
+ close(p[1]);
+
+ f = fdopen(p[0], "r");
+ if (!f) {
+ close(p[0]);
+ kill(pid, SIGKILL);
+ reap(pid);
+ goto nospace;
+ }
+
+ l = wv ? i+1 : 0;
+
+ free(getword(f));
+ if (feof(f)) {
+ fclose(f);
+ reap(pid);
+ return WRDE_SYNTAX;
+ }
+
+ while ((w = getword(f))) {
+ if (i+1 >= l) {
+ l += l/2+10;
+ tmp = realloc(wv, l*sizeof(char *));
+ if (!tmp) break;
+ wv = tmp;
+ }
+ wv[i++] = w;
+ wv[i] = 0;
+ }
+ if (!feof(f)) err = WRDE_NOSPACE;
+
+ fclose(f);
+ reap(pid);
+
+ if (!wv) wv = calloc(i+1, sizeof *wv);
+
+ we->we_wordv = wv;
+ we->we_wordc = i;
+
+ if (flags & WRDE_DOOFFS) {
+ if (wv) for (i=we->we_offs; i; i--)
+ we->we_wordv[i-1] = 0;
+ we->we_wordc -= we->we_offs;
+ }
+ return err;
+
+nospace:
+ if (!(flags & WRDE_APPEND)) {
+ we->we_wordc = 0;
+ we->we_wordv = 0;
+ }
+ return WRDE_NOSPACE;
+}
+
+int wordexp(const char *restrict s, wordexp_t *restrict we, int flags)
+{
+ int r, cs;
+ r = do_wordexp(s, we, flags);
+ return r;
+}
+
+void wordfree(wordexp_t *we)
+{
+ size_t i;
+ if (!we->we_wordv) return;
+ for (i=0; i<we->we_wordc; i++) free(we->we_wordv[we->we_offs+i]);
+ free(we->we_wordv);
+ we->we_wordv = 0;
+ we->we_wordc = 0;
+}
diff -uNr src/lxqt-session/src/wordexp.h src.mod/lxqt-session/src/wordexp.h
--- src/lxqt-session/src/wordexp.h 1970-01-01 00:00:00.000000000 +0000
+++ src.mod/lxqt-session/src/wordexp.h 2021-05-21 09:17:53.811283000 +0000
@@ -0,0 +1,58 @@
+/* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+#ifndef _WORDEXP_H
+#define _WORDEXP_H 1
+#include <features.h>
+#define __need_size_t
+#include <stddef.h>
+__BEGIN_DECLS
+/* Bits set in the FLAGS argument to `wordexp'. */
+enum
+ {
+ WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */
+ WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */
+ WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */
+ WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */
+ WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */
+ WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */
+ __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD |
+ WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF)
+ };
+/* Structure describing a word-expansion run. */
+typedef struct
+ {
+ size_t we_wordc; /* Count of words matched. */
+ char **we_wordv; /* List of expanded words. */
+ size_t we_offs; /* Slots to reserve in `we_wordv'. */
+ } wordexp_t;
+/* Possible nonzero return values from `wordexp'. */
+enum
+ {
+#ifdef __USE_XOPEN
+ WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */
+#endif
+ WRDE_NOSPACE = 1, /* Ran out of memory. */
+ WRDE_BADCHAR, /* A metachar appears in the wrong place. */
+ WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
+ WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
+ WRDE_SYNTAX /* Shell syntax error. */
+ };
+/* Do word expansion of WORDS into PWORDEXP. */
+extern int wordexp (__const char *__restrict __words,
+ wordexp_t *__restrict __pwordexp, int __flags);
+/* Free the storage allocated by a `wordexp' call. */
+extern void wordfree (wordexp_t *__wordexp);
+__END_DECLS
+#endif /* wordexp.h */

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="The LXQt session manager"
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="Simeon Huang <symeon@librehat.com>"
TERMUX_PKG_VERSION=0.17.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL="https://github.com/lxqt/lxqt-session/releases/download/${TERMUX_PKG_VERSION}/lxqt-session-${TERMUX_PKG_VERSION}.tar.xz"
TERMUX_PKG_SHA256=d9058ceedb355a43ea2ef070292fc30b0fb740640cf0b579131aaefbac779c47
TERMUX_PKG_DEPENDS="qt5-qtbase, qt5-qtx11extras, kwindowsystem, liblxqt, procps"

View File

@ -0,0 +1,53 @@
diff -uNr src/CMakeLists.txt src.mod/CMakeLists.txt
--- src/CMakeLists.txt 2021-05-21 09:22:54.192072000 +0000
+++ src.mod/CMakeLists.txt 2021-05-21 09:29:32.473671000 +0000
@@ -57,11 +57,11 @@
# startlxqt script
set(PREDEF_XDG_DATA_DIRS "$XDG_DATA_HOME")
-if(NOT("${LXQT_DATA_DIR}" MATCHES "^/usr(/local)?/share$"))
+if(NOT("${LXQT_DATA_DIR}" MATCHES "^@TERMUX_PREFIX@(/local)?/share$"))
set(PREDEF_XDG_DATA_DIRS "${PREDEF_XDG_DATA_DIRS}:${LXQT_DATA_DIR}")
endif()
-set(PREDEF_XDG_DATA_DIRS "${PREDEF_XDG_DATA_DIRS}:/usr/local/share:/usr/share")
-set(PREDEF_XDG_CONFIG_DIRS "/etc:${LXQT_ETC_XDG_DIR}:/usr/share")
+set(PREDEF_XDG_DATA_DIRS "${PREDEF_XDG_DATA_DIRS}:@TERMUX_PREFIX@/local/share:@TERMUX_PREFIX@/share")
+set(PREDEF_XDG_CONFIG_DIRS "@TERMUX_PREFIX@/etc:${LXQT_ETC_XDG_DIR}:@TERMUX_PREFIX@/share")
configure_file(startlxqt.in startlxqt @ONLY)
install(PROGRAMS
"${CMAKE_CURRENT_BINARY_DIR}/startlxqt"
diff -uNr src/lxqt-config-session/autostartedit.cpp src.mod/lxqt-config-session/autostartedit.cpp
--- src/lxqt-config-session/autostartedit.cpp 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/lxqt-config-session/autostartedit.cpp 2021-05-21 09:27:08.762448000 +0000
@@ -58,7 +58,7 @@
void AutoStartEdit::browse()
{
- QString filePath = QFileDialog::getOpenFileName(this, tr("Select Application"), QSL("/usr/bin/"));
+ QString filePath = QFileDialog::getOpenFileName(this, tr("Select Application"), QSL("@TERMUX_PREFIX@/bin/"));
if (!filePath.isEmpty())
ui->commandEdit->setText(filePath);
}
diff -uNr src/lxqt-config-session/sessionconfigwindow.cpp src.mod/lxqt-config-session/sessionconfigwindow.cpp
--- src/lxqt-config-session/sessionconfigwindow.cpp 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/lxqt-config-session/sessionconfigwindow.cpp 2021-05-21 09:26:22.519701000 +0000
@@ -115,7 +115,7 @@
const QString &prompt
)
{
- QString fname = QFileDialog::getOpenFileName(cb, prompt, QSL("/usr/bin/"));
+ QString fname = QFileDialog::getOpenFileName(cb, prompt, QSL("@TERMUX_PREFIX@/bin/"));
if (fname.isEmpty())
return;
diff -uNr src/lxqt-session/src/wmselectdialog.cpp src.mod/lxqt-session/src/wmselectdialog.cpp
--- src/lxqt-session/src/wmselectdialog.cpp 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/lxqt-session/src/wmselectdialog.cpp 2021-05-21 09:25:20.941811000 +0000
@@ -117,7 +117,7 @@
if (item->data(1, TYPE_ROLE) != SELECT_DLG_TYPE)
return;
- QString fname = QFileDialog::getOpenFileName(this, QString(), QSL("/usr/bin/"));
+ QString fname = QFileDialog::getOpenFileName(this, QString(), QSL("@TERMUX_PREFIX@/bin/"));
if (fname.isEmpty())
return;

View File

@ -1,6 +1,3 @@
This patch removes the check on CMake system's name "Linux".
Because Termux is considered to be Q_OS_LINUX and not Q_OS_ANDROID.
This patch also removes the check on non-existent XdgUserDirs package.
--- src/CMakeLists.txt 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/CMakeLists.txt 2021-05-20 14:57:23.675649000 +0000
@@ -32,12 +32,7 @@

View File

@ -1,32 +0,0 @@
--- src/lxqt-session/src/lxqtmodman.cpp 2021-04-16 16:36:14.000000000 +0000
+++ src.mod/lxqt-session/src/lxqtmodman.cpp 2021-05-20 15:05:04.165344000 +0000
@@ -43,7 +43,6 @@
#include <QDateTime>
#include "wmselectdialog.h"
#include "windowmanager.h"
-#include <wordexp.h>
#include "log.h"
#include <KWindowSystem/KWindowSystem>
@@ -429,20 +428,7 @@
void lxqt_setenv(const char *env, const QByteArray &value)
{
- wordexp_t p;
- wordexp(value.constData(), &p, 0);
- if (p.we_wordc == 1)
- {
-
- qCDebug(SESSION) << "Environment variable" << env << "=" << p.we_wordv[0];
- qputenv(env, p.we_wordv[0]);
- }
- else
- {
- qCWarning(SESSION) << "Error expanding environment variable" << env << "=" << value;
- qputenv(env, value);
- }
- wordfree(&p);
+ qputenv(env, value);
}
void lxqt_setenv_prepend(const char *env, const QByteArray &value, const QByteArray &separator)