Package init

This commit is contained in:
overweight 2019-09-30 10:35:10 -04:00
commit 02f6c99d1a
8 changed files with 753 additions and 0 deletions

View File

@ -0,0 +1,28 @@
From 078a271ef3dbfcb99b78a433166b4ee6e560b2ff Mon Sep 17 00:00:00 2001
From: Jan Macku <jamacku@redhat.com>
Date: Fri, 8 Mar 2019 16:43:58 +0100
Subject: [PATCH] Remove mistakenly added text
---
alternatives.8 | 8 --------
1 file changed, 8 deletions(-)
diff --git a/alternatives.8 b/alternatives.8
index a512873..b2f938e 100644
--- a/alternatives.8
+++ b/alternatives.8
@@ -448,11 +448,3 @@ version 2 or later for copying conditions. There is NO WARRANTY.
.SH "SEE ALSO"
.BR ln (1),
FHS, the Filesystem Hierarchy Standard.
-alternatives.c
-chkconfig.c
-COPYING
-leveldb.c
-leveldb.h
-Makefile
-ntsysv.c
-ook
--
2.21.0.windows.1

View File

@ -0,0 +1,78 @@
From 049c69f5c73ec399311548774a055b3bac6968f9 Mon Sep 17 00:00:00 2001
From: luochunsheng <luochunsheng@huawei.com>
Date: Tue, 9 Apr 2019 20:38:13 +0800
Subject: [PATCH] added check if correct symlink exists
---
alternatives.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/alternatives.c b/alternatives.c
index cdfec6d..b02cce2 100644
--- a/alternatives.c
+++ b/alternatives.c
@@ -456,6 +456,7 @@ static int removeLinks(struct linkSet * l, const char * altDir, int flags) {
static int makeLinks(struct linkSet * l, const char * altDir, int flags) {
char * sl;
+ char buf[PATH_MAX];
sl = alloca(strlen(altDir) + strlen(l->title) + 2);
sprintf(sl, "%s/%s", altDir, l->title);
@@ -463,12 +464,17 @@ static int makeLinks(struct linkSet * l, const char * altDir, int flags) {
if (FL_TEST(flags)) {
printf(_("would link %s -> %s\n"), l->facility, sl);
} else {
- unlink(l->facility);
+ memset(buf, 0, sizeof(buf));
+ readlink(l->facility, buf, sizeof(buf));
- if (symlink(sl, l->facility)) {
- fprintf(stderr, _("failed to link %s -> %s: %s\n"),
- l->facility, sl, strerror(errno));
- return 1;
+ if(strcmp(sl, buf) != 0) {
+ unlink(l->facility);
+
+ if (symlink(sl, l->facility)) {
+ fprintf(stderr, _("failed to link %s -> %s: %s\n"), l->facility,
+ sl, strerror(errno));
+ return 1;
+ }
}
}
} else
@@ -478,16 +484,21 @@ static int makeLinks(struct linkSet * l, const char * altDir, int flags) {
if (FL_TEST(flags)) {
printf(_("would link %s -> %s\n"), sl, l->target);
} else {
- if (unlink(sl) && errno != ENOENT){
- fprintf(stderr, _("failed to remove link %s: %s\n"),
- sl, strerror(errno));
- return 1;
- }
+ memset(buf, 0, sizeof(buf));
+ readlink(sl, buf, sizeof(buf));
+
+ if(strcmp(l->target, buf) != 0) {
+ if (unlink(sl) && errno != ENOENT) {
+ fprintf(stderr, _("failed to remove link %s: %s\n"), sl,
+ strerror(errno));
+ return 1;
+ }
- if (symlink(l->target, sl)) {
- fprintf(stderr, _("failed to link %s -> %s: %s\n"),
- sl, l->target, strerror(errno));
- return 1;
+ if (symlink(l->target, sl)) {
+ fprintf(stderr, _("failed to link %s -> %s: %s\n"), sl, l->target,
+ strerror(errno));
+ return 1;
+ }
}
}
--
1.8.3.1

View File

@ -0,0 +1,48 @@
From ea46d5c41457be0987c8d16bcefec9ad196b06c8 Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Sat, 26 Jan 2019 08:56:48 -0500
Subject: [PATCH] bugfix: huawei-bugfix-alternatives-prettier-list-output
---
alternatives.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/alternatives.c b/alternatives.c
index c1a68db..2f60011 100644
--- a/alternatives.c
+++ b/alternatives.c
@@ -946,20 +946,27 @@ static int removeAll(const char * title, const char * altDir, const char * state
static int listServices(const char * altDir, const char * stateDir, int flags) {
DIR *dir;
struct dirent *ent;
- dir = opendir(stateDir);
struct alternativeSet set;
+ int max_name = 0;
+ int l;
+ dir = opendir(stateDir);
if(dir == NULL)
return 2;
while((ent = readdir(dir)) != NULL) {
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
continue;
-
+ l = strlen(ent->d_name);
+ max_name = max_name > l ? max_name : l;
+ }
+ rewinddir(dir);
+ while((ent = readdir(dir)) != NULL) {
+ if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
+ continue;
if (readConfig(&set, ent->d_name, altDir, stateDir, flags))
return 2;
-
- printf("%s\t%s\t%s\n", ent->d_name, set.mode == AUTO?"auto":"manual", set.currentLink);
+ printf("%-*s\t%s\t%s\n", max_name, ent->d_name, set.mode == AUTO?"auto ":"manual", set.currentLink);
}
closedir(dir);
--
1.8.3.1

View File

@ -0,0 +1,402 @@
From ea44baee1c8f424cb49aea59ccc58db0a0147be3 Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Sat, 26 Jan 2019 09:00:48 -0500
Subject: [PATCH] bugfix: huawei-bugfix-leveldb-don-t-crash-on-long-names
---
leveldb.c | 13 +++++--
po/chkconfig.pot | 117 +++++++++++++++++++++++++++++--------------------------
2 files changed, 70 insertions(+), 60 deletions(-)
diff --git a/leveldb.c b/leveldb.c
index 52d5970..b8cf21c 100644
--- a/leveldb.c
+++ b/leveldb.c
@@ -705,23 +705,28 @@ int currentRunlevel(void) {
}
int findServiceEntries(char * name, int level, glob_t * globresptr) {
- char match[200];
+ char *match;
glob_t globres;
int rc;
- sprintf(match, "%s/rc%d.d/[SK][0-9][0-9]%s", RUNLEVELS, level, name);
-
+ rc = asprintf(&match, "%s/rc%d.d/[SK][0-9][0-9]%s", RUNLEVELS, level, name);
+ if (rc < 0) {
+ fprintf(stderr, _("failed to glob pattern %s: %s\n"), match,strerror(errno));
+ return 1;
+ }
rc = glob(match, GLOB_ERR | GLOB_NOSORT, NULL, &globres);
if (rc && rc != GLOB_NOMATCH) {
fprintf(stderr, _("failed to glob pattern %s: %s\n"), match,
strerror(errno));
+ free(match);
return 1;
} else if (rc == GLOB_NOMATCH) {
globresptr->gl_pathc = 0;
+ free(match);
return 0;
}
-
+ free(match);
*globresptr = globres;
return 0;
}
diff --git a/po/chkconfig.pot b/po/chkconfig.pot
index 813d10e..88c8c0c 100644
--- a/po/chkconfig.pot
+++ b/po/chkconfig.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-06-29 14:31+0200\n"
+"POT-Creation-Date: 2017-06-09 14:53+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -207,22 +207,22 @@ msgstr ""
msgid "failed to open %s/init.d: %s\n"
msgstr ""
-#: ../leveldb.c:717
+#: ../leveldb.c:715 ../leveldb.c:723
#, c-format
msgid "failed to glob pattern %s: %s\n"
msgstr ""
-#: ../leveldb.c:760
+#: ../leveldb.c:768
#, c-format
msgid "cannot determine current run level\n"
msgstr ""
-#: ../leveldb.c:840
+#: ../leveldb.c:848
#, c-format
msgid "Unable to set selinux context for %s: %s\n"
msgstr ""
-#: ../leveldb.c:864
+#: ../leveldb.c:872
#, c-format
msgid "failed to make symlink %s: %s\n"
msgstr ""
@@ -291,255 +291,260 @@ msgstr ""
#: ../alternatives.c:80
#, c-format
-msgid "\n"
+msgid " alternatives --remove-all <name>\n"
msgstr ""
#: ../alternatives.c:81
#, c-format
+msgid "\n"
+msgstr ""
+
+#: ../alternatives.c:82
+#, c-format
msgid ""
"common options: --verbose --test --help --usage --version --keep-missing\n"
msgstr ""
-#: ../alternatives.c:82
+#: ../alternatives.c:83
#, c-format
msgid " --altdir <directory> --admindir <directory>\n"
msgstr ""
-#: ../alternatives.c:214
+#: ../alternatives.c:215
#, c-format
msgid "reading %s\n"
msgstr ""
-#: ../alternatives.c:218
+#: ../alternatives.c:219
#, c-format
msgid "failed to open %s: %s\n"
msgstr ""
-#: ../alternatives.c:227
+#: ../alternatives.c:228
#, c-format
msgid "failed to read %s: %s\n"
msgstr ""
-#: ../alternatives.c:236
+#: ../alternatives.c:237
#, c-format
msgid "%s empty!\n"
msgstr ""
-#: ../alternatives.c:245
+#: ../alternatives.c:246
#, c-format
msgid "bad mode on line 1 of %s\n"
msgstr ""
-#: ../alternatives.c:252
+#: ../alternatives.c:253
#, c-format
msgid "bad primary link in %s\n"
msgstr ""
-#: ../alternatives.c:264
+#: ../alternatives.c:265
#, c-format
msgid "path %s unexpected in %s\n"
msgstr ""
-#: ../alternatives.c:273
+#: ../alternatives.c:274
#, c-format
msgid "missing path for slave %s in %s\n"
msgstr ""
-#: ../alternatives.c:283
+#: ../alternatives.c:284
#, c-format
msgid "unexpected end of file in %s\n"
msgstr ""
-#: ../alternatives.c:292
+#: ../alternatives.c:293
#, c-format
msgid "path to alternate expected in %s\n"
msgstr ""
-#: ../alternatives.c:293 ../alternatives.c:318 ../alternatives.c:330
-#: ../alternatives.c:347 ../alternatives.c:366
+#: ../alternatives.c:294 ../alternatives.c:319 ../alternatives.c:331
+#: ../alternatives.c:348 ../alternatives.c:367
#, c-format
msgid "unexpected line in %s: %s\n"
msgstr ""
-#: ../alternatives.c:317
+#: ../alternatives.c:318
#, c-format
msgid "closing '@' missing or the family is empty in %s\n"
msgstr ""
-#: ../alternatives.c:329
+#: ../alternatives.c:330
#, c-format
msgid "numeric priority expected in %s\n"
msgstr ""
-#: ../alternatives.c:346
+#: ../alternatives.c:347
#, c-format
msgid "slave path expected in %s\n"
msgstr ""
-#: ../alternatives.c:374
+#: ../alternatives.c:375
#, c-format
msgid "failed to read link %s: %s\n"
msgstr ""
-#: ../alternatives.c:388
+#: ../alternatives.c:389
#, c-format
msgid "link points to no alternative -- setting mode to manual\n"
msgstr ""
-#: ../alternatives.c:393
+#: ../alternatives.c:394
#, c-format
msgid "link changed -- setting mode to manual\n"
msgstr ""
-#: ../alternatives.c:424 ../alternatives.c:431
+#: ../alternatives.c:425 ../alternatives.c:432
#, c-format
msgid "would remove %s\n"
msgstr ""
-#: ../alternatives.c:426 ../alternatives.c:433 ../alternatives.c:466
+#: ../alternatives.c:427 ../alternatives.c:434 ../alternatives.c:467
#, c-format
msgid "failed to remove link %s: %s\n"
msgstr ""
-#: ../alternatives.c:448 ../alternatives.c:463
+#: ../alternatives.c:449 ../alternatives.c:464
#, c-format
msgid "would link %s -> %s\n"
msgstr ""
-#: ../alternatives.c:453 ../alternatives.c:472
+#: ../alternatives.c:454 ../alternatives.c:473
#, c-format
msgid "failed to link %s -> %s: %s\n"
msgstr ""
-#: ../alternatives.c:459
+#: ../alternatives.c:460
#, c-format
msgid "failed to link %s -> %s: %s exists and it is not a symlink\n"
msgstr ""
-#: ../alternatives.c:504
+#: ../alternatives.c:505
#, c-format
msgid "%s already exists\n"
msgstr ""
-#: ../alternatives.c:506
+#: ../alternatives.c:507
#, c-format
msgid "failed to create %s: %s\n"
msgstr ""
-#: ../alternatives.c:539
+#: ../alternatives.c:540
#, c-format
msgid "failed to replace %s with %s: %s\n"
msgstr ""
-#: ../alternatives.c:565 ../alternatives.c:571 ../alternatives.c:582
-#: ../alternatives.c:588
+#: ../alternatives.c:566 ../alternatives.c:572 ../alternatives.c:583
+#: ../alternatives.c:589
#, c-format
msgid "running %s\n"
msgstr ""
-#: ../alternatives.c:618
+#: ../alternatives.c:619
#, c-format
msgid "the primary link for %s must be %s\n"
msgstr ""
-#: ../alternatives.c:699
+#: ../alternatives.c:700
#, c-format
msgid "link %s incorrect for slave %s (%s %s)\n"
msgstr ""
-#: ../alternatives.c:740
+#: ../alternatives.c:741
#, c-format
msgid "%s - status is auto.\n"
msgstr ""
-#: ../alternatives.c:742
+#: ../alternatives.c:743
#, c-format
msgid "%s - status is manual.\n"
msgstr ""
-#: ../alternatives.c:744
+#: ../alternatives.c:745
#, c-format
msgid " link currently points to %s\n"
msgstr ""
-#: ../alternatives.c:749
+#: ../alternatives.c:750
#, c-format
msgid "family %s "
msgstr ""
-#: ../alternatives.c:750
+#: ../alternatives.c:751
#, c-format
msgid "priority %d\n"
msgstr ""
-#: ../alternatives.c:752
+#: ../alternatives.c:753
#, c-format
msgid " slave %s: %s\n"
msgstr ""
-#: ../alternatives.c:757
+#: ../alternatives.c:758
#, c-format
msgid "Current `best' version is %s.\n"
msgstr ""
-#: ../alternatives.c:788
+#: ../alternatives.c:789
#, c-format
msgid "There is %d program that provides '%s'.\n"
msgstr ""
-#: ../alternatives.c:788
+#: ../alternatives.c:789
#, c-format
msgid "There are %d programs which provide '%s'.\n"
msgstr ""
-#: ../alternatives.c:790
+#: ../alternatives.c:791
#, c-format
msgid " Selection Command\n"
msgstr ""
-#: ../alternatives.c:804
+#: ../alternatives.c:805
#, c-format
msgid "Enter to keep the current selection[+], or type selection number: "
msgstr ""
-#: ../alternatives.c:807
+#: ../alternatives.c:808
#, c-format
msgid ""
"\n"
"error reading choice\n"
msgstr ""
-#: ../alternatives.c:844 ../alternatives.c:872
+#: ../alternatives.c:845 ../alternatives.c:873
#, c-format
msgid "%s has not been configured as an alternative for %s\n"
msgstr ""
-#: ../alternatives.c:888
+#: ../alternatives.c:889
#, c-format
msgid "(would remove %s\n"
msgstr ""
-#: ../alternatives.c:890
+#: ../alternatives.c:891
#, c-format
msgid "failed to remove %s: %s\n"
msgstr ""
-#: ../alternatives.c:1009
+#: ../alternatives.c:1038
#, c-format
msgid "--family can't contain the symbol '@'\n"
msgstr ""
-#: ../alternatives.c:1062
+#: ../alternatives.c:1093
#, c-format
msgid "altdir %s invalid\n"
msgstr ""
-#: ../alternatives.c:1068
+#: ../alternatives.c:1099
#, c-format
msgid "admindir %s invalid\n"
msgstr ""
-#: ../alternatives.c:1078
+#: ../alternatives.c:1109
#, c-format
msgid "alternatives version %s\n"
msgstr ""
--
1.8.3.1

BIN
chkconfig-1.10.tar.gz Normal file

Binary file not shown.

66
chkconfig.spec Normal file
View File

@ -0,0 +1,66 @@
Name: chkconfig
Version: 1.10
Release: 7
Summary: chkconfig updates and queries runlevel information for system services
License: GPLv2
URL: https://github.com/fedora-sysv/chkconfig
Source0: https://github.com/fedora-sysv/chkconfig/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch6000: bugfix-alternatives-prettier-list-output.patch
Patch6001: bugfix-leveldb-don-t-crash-on-long-names.patch
Patch6002: man-alternatives-list-does-not-accept-name.patch
Patch6003: paths-to-targets-and-facilities-normalized-bug-14853.patch
Patch6004: added-check-if-correct-symlink-exists.patch
Patch6005: Remove-mistakenly-added-text.patch
BuildRequires: gcc newt-devel gettext popt-devel libselinux-devel
Conflicts: initscripts <= 5.30-1
Provides: ntsysv
%description
chkconfig provides a simple command-line tool for maintaining
the /etc/rc[0-6].d directory hierarchy by relieving system
administrators of the task of directly manipulating the numerous
symbolic links in those directories.
%package_help
%prep
%autosetup -p1
%build
%make_build RPM_OPT_FLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
%check
make check
%install
%make_install MANDIR=%{_mandir} SBINDIR=%{_sbindir}
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
for i in {0..6};do
mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc${i}.d
done
ln -s rc.d/init.d %{buildroot}%{_sysconfdir}/init.d
for i in {0..6};do
ln -s rc.d/rc${i}.d %{buildroot}%{_sysconfdir}/rc${i}.d
done
mkdir -p %{buildroot}%{_sysconfdir}/chkconfig.d
%files
%dir %{_sysconfdir}/alternatives
%dir /var/lib/alternatives
%{_sysconfdir}/{init.d,rc.d,rc[0-6].d}
%{_sysconfdir}/rc.d/{inid.d,rc[0-6].d}
%{_sysconfdir}/chkconfig.d
%{_sbindir}/{*alternatives,ntsysv}
/sbin/chkconfig
%{_prefix}/lib/systemd/systemd-sysv-install
%license COPYING
%{_datadir}/locale/*/LC_MESSAGES/chkconfig.mo
%files help
%{_mandir}/man8/*
%changelog
* Fri Aug 30 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.10-7
- Package Init

View File

@ -0,0 +1,24 @@
From 3e7257fe4bf7ec253a782fa6a9e5f061bbf8ddde Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Tue, 2 Oct 2018 17:48:42 +0200
Subject: [PATCH] man: alternatives --list does not accept name
---
alternatives.8 | 1 -
1 file changed, 1 deletion(-)
diff --git a/alternatives.8 b/alternatives.8
index 941dba4..a512873 100644
--- a/alternatives.8
+++ b/alternatives.8
@@ -48,7 +48,6 @@ alternatives \- maintain symbolic links determining default commands
.B alternatives
.RI [ options ]
.B --list
-.I name
.PP
.B alternatives
.RI [ options ]
--
2.21.0.windows.1

View File

@ -0,0 +1,107 @@
From 624427e2c458ec94fe6ef33e9efeb7876042aa21 Mon Sep 17 00:00:00 2001
From: luochunsheng <luochunsheng@huawei.com>
Date: Tue, 9 Apr 2019 20:18:39 +0800
Subject: [PATCH] paths to targets and facilities normalized, bug #1485304
---
alternatives.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/alternatives.c b/alternatives.c
index c1a68db..cdfec6d 100644
--- a/alternatives.c
+++ b/alternatives.c
@@ -85,6 +85,21 @@ static int usage(int rc) {
exit(rc);
}
+const char *normalize_path(const char *s) {
+ if (s) {
+ const char *src = s;
+ char *dst = (char *)s;
+ while ((*dst = *src) != '\0') {
+ do {
+ src++;
+ } while (*dst == '/' && *src == '/');
+ dst++;
+ }
+ }
+ return (const char *)s;
+}
+
+
int streq(const char *a, const char *b) {
if (a && b)
return strcmp(a, b) ? 0 : 1;
@@ -147,7 +162,7 @@ static void setupDoubleArg(enum programModes * mode, const char *** nextArgPtr,
nextArg++;
if (!*nextArg) usage(2);
- *target = strdup(*nextArg);
+ *target = strdup(normalize_path(*nextArg));
*nextArgPtr = nextArg + 1;
}
@@ -155,7 +170,7 @@ static void setupLinkSet(struct linkSet * set, const char *** nextArgPtr) {
const char ** nextArg = *nextArgPtr;
if (!*nextArg || **nextArg != '/') usage(2);
- set->facility = strdup(*nextArg);
+ set->facility = strdup(normalize_path(*nextArg));
nextArg++;
if (!*nextArg || **nextArg == '/') usage(2);
@@ -163,7 +178,7 @@ static void setupLinkSet(struct linkSet * set, const char *** nextArgPtr) {
nextArg++;
if (!*nextArg || **nextArg != '/') usage(2);
- set->target = strdup(*nextArg);
+ set->target = strdup(normalize_path(*nextArg));
*nextArgPtr = nextArg + 1;
}
@@ -295,7 +310,7 @@ static int readConfig(struct alternativeSet * set, const char * title,
return 1;
}
- set->alts[set->numAlts].master.facility = strdup(groups[0].facility);
+ set->alts[set->numAlts].master.facility = strdup(normalize_path(groups[0].facility));
set->alts[set->numAlts].master.title = strdup(groups[0].title);
set->alts[set->numAlts].master.target = line;
set->alts[set->numAlts].numSlaves = numGroups - 1;
@@ -352,7 +367,7 @@ static int readConfig(struct alternativeSet * set, const char * title,
set->alts[set->numAlts].slaves[i - 1].title =
strdup(groups[i].title);
set->alts[set->numAlts].slaves[i - 1].facility =
- strdup(groups[i].facility);
+ strdup(normalize_path(groups[i].facility));
set->alts[set->numAlts].slaves[i - 1].target = (line && strlen(line)) ? line : NULL;
}
@@ -396,7 +411,7 @@ static int readConfig(struct alternativeSet * set, const char * title,
set->current = i;
}
- set->currentLink = strdup(linkBuf);
+ set->currentLink = strdup(normalize_path(linkBuf));
return 0;
}
@@ -1060,12 +1075,12 @@ int main(int argc, const char ** argv) {
} else if (!strcmp(*nextArg, "--altdir")) {
nextArg++;
if (!*nextArg) usage(2);
- altDir = strdup(*nextArg);
+ altDir = strdup(normalize_path(*nextArg));
nextArg++;
} else if (!strcmp(*nextArg, "--admindir")) {
nextArg++;
if (!*nextArg) usage(2);
- stateDir = strdup(*nextArg);
+ stateDir = strdup(normalize_path(*nextArg));
nextArg++;
} else if (!strcmp(*nextArg, "--list")) {
if (mode != MODE_UNKNOWN) usage(2);
--
1.8.3.1