From e8a89e8985a5ed962bd6bc6217d3830fa418aed1 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 11 May 2026 18:52:37 -0400 Subject: [PATCH] More of the same --- src/globals.c | 2 -- src/remote-cstms.c | 23 ++++++++----------- src/remote-stub.c | 6 +++-- src/rule.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ src/rule.h | 6 +++-- 5 files changed, 75 insertions(+), 19 deletions(-) diff --git a/src/globals.c b/src/globals.c index bfd198347..8d820e0a1 100644 --- a/src/globals.c +++ b/src/globals.c @@ -138,8 +138,6 @@ The value is set in job.c. */ extern const char *default_shell; -char *remote_description = 0; - /* Remember the original value of the SHELL variable, from the environment. */ struct variable shell_var; diff --git a/src/remote-cstms.c b/src/remote-cstms.c index e33692882..c8543f9fd 100644 --- a/src/remote-cstms.c +++ b/src/remote-cstms.c @@ -3,7 +3,7 @@ Please do not send bug reports or questions about it to the Make maintainers. -Copyright (C) 1988-2020 Free Software Foundation, Inc. +Copyright (C) 1988-2022 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify it under the @@ -16,15 +16,18 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program. If not, see . */ +this program. If not, see . */ #include "makeint.h" + #include "filedef.h" -#include "commands.h" #include "job.h" +#include "commands.h" #include "debug.h" -#include +#if HAVE_SYS_TIME_H +# include +#endif #include #include "customs.h" @@ -74,19 +77,12 @@ start_remote_job_p (int first_p) return 0; } - /* For secure Customs, make is installed setuid root and - Customs requires a privileged source port be used. */ - make_access (); - if (ISDB (DB_JOBS)) Rpc_Debug (1); /* Ping the daemon once to see if it is there. */ inited = Customs_Ping () == RPC_SUCCESS ? 1 : -1; - /* Return to normal user access. */ - user_access (); - if (starting_directory == 0) /* main couldn't figure it out. */ inited = -1; @@ -172,7 +168,7 @@ start_remote_job (char **argv, char **envp, int stdin_fd, len = Customs_MakeWayBill (&permit, normalized_cwd, argv[0], argv, envp, retport, waybill); - /* Modify the waybill as if the remote child had done 'child_access ()'. */ + /* Modify the waybill for the child's uid/gid. */ { WayBill *wb = (WayBill *) waybill; wb->ruid = wb->euid; @@ -232,7 +228,8 @@ start_remote_job (char **argv, char **envp, int stdin_fd, else if (pid == 0) { /* Child side. Run 'export' to handle the connection. */ - static char sock_buf[20], retsock_buf[20], id_buf[20]; + static char sock_buf[INTSTR_LENGTH], retsock_buf[INTSTR_LENGTH]; + static char id_buf[INTSTR_LENGTH]; static char *new_argv[6] = { EXPORT_COMMAND, "-id", sock_buf, retsock_buf, id_buf, 0 }; diff --git a/src/remote-stub.c b/src/remote-stub.c index 67e32629b..d7cc260c5 100644 --- a/src/remote-stub.c +++ b/src/remote-stub.c @@ -1,5 +1,5 @@ /* Template for the remote job exportation interface to GNU Make. -Copyright (C) 1988-2020 Free Software Foundation, Inc. +Copyright (C) 1988-2022 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify it under the @@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program. If not, see . */ +this program. If not, see . */ #include "makeint.h" #include "filedef.h" @@ -20,6 +20,8 @@ this program. If not, see . */ #include "commands.h" +char *remote_description = 0; + /* Call once at startup even if no commands are run. */ void diff --git a/src/rule.c b/src/rule.c index 0eaeb729f..ded74e1b0 100644 --- a/src/rule.c +++ b/src/rule.c @@ -59,6 +59,63 @@ struct file *suffix_file; /* Maximum length of a suffix. */ static size_t maxsuffix; + +/* Return the rule definition: space separated rule targets, followed by + either a colon or two colons in the case of a terminal rule, followed by + space separated rule prerequisites, followed by a pipe, followed by + order-only prerequisites, if present. */ + +const char * +get_rule_defn (struct rule *r) +{ + if (r->_defn == NULL) + { + size_t len = 8; /* Reserve for ":: ", " | ", and nul. */ + unsigned int k; + char *p; + const char *sep = ""; + const struct dep *dep, *ood = 0; + + for (k = 0; k < r->num; ++k) + len += r->lens[k] + 1; + + for (dep = r->deps; dep; dep = dep->next) + len += strlen (dep_name (dep)) + (dep->wait_here ? CSTRLEN (" .WAIT") : 0) + 1; + + p = r->_defn = xmalloc (len); + for (k = 0; k < r->num; ++k, sep = " ") + p = mempcpy (mempcpy (p, sep, strlen (sep)), r->targets[k], r->lens[k]); + *p++ = ':'; + if (r->terminal) + *p++ = ':'; + + /* Copy all normal dependencies; note any order-only deps. */ + for (dep = r->deps; dep; dep = dep->next) + if (dep->ignore_mtime == 0) + { + if (dep->wait_here) + p = mempcpy (p, " .WAIT", CSTRLEN (" .WAIT")); + p = mempcpy (mempcpy (p, " ", 1), dep_name (dep), + strlen (dep_name (dep))); + } + else if (ood == 0) + ood = dep; + + /* Copy order-only deps, if we have any. */ + for (sep = " | "; ood; ood = ood->next, sep = " ") + if (ood->ignore_mtime) + { + p = mempcpy (p, sep, strlen (sep)); + if (ood->wait_here) + p = mempcpy (p, ".WAIT ", CSTRLEN (".WAIT ")); + p = mempcpy (p, dep_name (ood), strlen (dep_name (ood))); + } + *p = '\0'; + } + + return r->_defn; +} + /* Compute the maximum dependency length and maximum number of dependencies of all implicit rules. Also sets the subdir flag for a rule when appropriate, diff --git a/src/rule.h b/src/rule.h index 2235b6701..75843e8ac 100644 --- a/src/rule.h +++ b/src/rule.h @@ -1,5 +1,5 @@ /* Definitions for using pattern rules in GNU Make. -Copyright (C) 1988-2020 Free Software Foundation, Inc. +Copyright (C) 1988-2022 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify it under the @@ -12,7 +12,7 @@ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program. If not, see . */ +this program. If not, see . */ /* Structure used for pattern (implicit) rules. */ @@ -30,6 +30,7 @@ struct rule const char **suffixes; /* Suffixes (after '%') of each target. */ struct dep *deps; /* Dependencies of the rule. */ struct commands *cmds; /* Commands to execute. */ + char *_defn; /* Definition of the rule. */ unsigned short num; /* Number of targets. */ char terminal; /* If terminal (double-colon). */ char in_use; /* If in use by a parent pattern_search. */ @@ -64,6 +65,7 @@ void create_pattern_rule (const char **targets, const char **target_percents, /*! Show information about a given rule. Useful from the debugger or gdb. */ extern void print_rule (rule_t *r, bool b_verbose); +const char *get_rule_defn (struct rule *rule); extern void print_rule_data_base (bool b_verbose); #endif /*REMAKE_RULE_H*/