Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 699917 Details for
Bug 756390
Please allow multiple --initscript in alternatives
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
potential patch
alternatives.patch (text/plain), 6.57 KB, created by
Lukáš Nykrýn
on 2013-02-20 10:02:53 UTC
(
hide
)
Description:
potential patch
Filename:
MIME Type:
Creator:
Lukáš Nykrýn
Created:
2013-02-20 10:02:53 UTC
Size:
6.57 KB
patch
obsolete
>diff --git a/alternatives.c b/alternatives.c >index 4d87627..28d8409 100644 >--- a/alternatives.c >+++ b/alternatives.c >@@ -43,7 +43,7 @@ struct alternative { > int priority; > struct linkSet master; > struct linkSet * slaves; >- char *initscript; >+ char **initscript; > int numSlaves; > }; > >@@ -288,10 +288,22 @@ static int readConfig(struct alternativeSet * set, const char * title, > return 1; > } > if (end) { >- while (*end && isspace(*end)) end++; >- if (strlen(end)) { >- set->alts[set->numAlts].initscript = strdup(end); >- } >+ char delims[] = " "; >+ char *result = NULL; >+ char **p; >+ int i; >+ result = strtok(end, delims); >+ for (i = 0; result != NULL; i++) { >+ p = realloc(set->alts[set->numAlts].initscript, (i+2) * sizeof(char *)); >+ if(p == NULL) >+ return 1; >+ set->alts[set->numAlts].initscript = p; >+ set->alts[set->numAlts].initscript[i] = strdup(result); >+ if(set->alts[set->numAlts].initscript[i] == NULL) >+ return 1; >+ set->alts[set->numAlts].initscript[i+1] = NULL; >+ result = strtok(NULL, delims); >+ } > } > > if (set->alts[set->numAlts].priority > set->alts[set->best].priority) >@@ -472,11 +484,11 @@ static int writeState(struct alternativeSet * set, const char * altDir, > > for (i = 0; i < set->numAlts; i++) { > fprintf(f, "%s\n", set->alts[i].master.target); >- if (set->alts[i].initscript) >- fprintf(f, "%d %s\n", set->alts[i].priority, set->alts[i].initscript); >- else >- fprintf(f, "%d\n", set->alts[i].priority); >- >+ fprintf(f, "%d", set->alts[i].priority); >+ if (set->alts[i].initscript) >+ for (j = 0; set->alts[i].initscript[j]; j++) >+ fprintf(f, " %s", set->alts[i].initscript[j]); >+ fprintf(f, "\n"); > for (j = 0; j < set->alts[i].numSlaves; j++) { > if (set->alts[i].slaves[j].target) > fprintf(f, "%s", set->alts[i].slaves[j].target); >@@ -509,38 +521,40 @@ static int writeState(struct alternativeSet * set, const char * altDir, > } > > if (!FL_TEST(flags)) { >- if (alt->initscript) { >- if (isSystemd(alt->initscript)) { >- asprintf(&path, "/bin/systemctl -q enable %s.service", alt->initscript); >- if (FL_VERBOSE(flags)) >- printf(_("running %s\n"), path); >- system(path); >- free(path); >- } else { >- asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript); >- if (FL_VERBOSE(flags)) >- printf(_("running %s\n"), path); >- system(path); >- free(path); >- } >- } >- for (i = 0; i < set->numAlts ; i++) { >- struct alternative * tmpalt = set->alts + i; >- if (tmpalt != alt && tmpalt->initscript) { >- if (isSystemd(tmpalt->initscript)) { >- asprintf(&path, "/bin/systemctl -q disable %s.service", tmpalt->initscript); >+ if (alt->initscript) >+ for (i=0; alt->initscript[i]; i++){ >+ if (isSystemd(alt->initscript[i])) { >+ asprintf(&path, "/bin/systemctl -q enable %s.service", alt->initscript[i]); > if (FL_VERBOSE(flags)) >- printf(_("running %s\n"), path); >+ printf(_("running %s\n"), path); > system(path); > free(path); > } else { >- asprintf(&path, "/sbin/chkconfig --del %s", tmpalt->initscript); >+ asprintf(&path, "/sbin/chkconfig --add %s", alt->initscript[i]); > if (FL_VERBOSE(flags)) >- printf(_("running %s\n"), path); >+ printf(_("running %s\n"), path); > system(path); > free(path); > } >- } >+ } >+ for (i = 0; i < set->numAlts ; i++) { >+ struct alternative * tmpalt = set->alts + i; >+ if (tmpalt != alt && tmpalt->initscript) >+ for (j=0; tmpalt->initscript[j]; j++){ >+ if (isSystemd(tmpalt->initscript[j])) { >+ asprintf(&path, "/bin/systemctl -q disable %s.service", tmpalt->initscript[j]); >+ if (FL_VERBOSE(flags)) >+ printf(_("running %s\n"), path); >+ system(path); >+ free(path); >+ } else { >+ asprintf(&path, "/sbin/chkconfig --del %s", tmpalt->initscript[j]); >+ if (FL_VERBOSE(flags)) >+ printf(_("running %s\n"), path); >+ system(path); >+ free(path); >+ } >+ } > } > } > >@@ -859,6 +873,8 @@ int main(int argc, const char ** argv) { > char * altDir = "/etc/alternatives"; > char * stateDir = "/var/lib/alternatives"; > struct stat sb; >+ int n_initscript = 0; >+ char **p; > > setlocale(LC_ALL, ""); > bindtextdomain("chkconfig","/usr/share/locale"); >@@ -894,7 +910,15 @@ int main(int argc, const char ** argv) { > nextArg++; > > if (!*nextArg) usage(2); >- newAlt.initscript = strdup(*nextArg); >+ p = realloc(newAlt.initscript, (n_initscript + 2) * sizeof(char *)); >+ if (p == NULL) >+ return 1; >+ newAlt.initscript = p; >+ newAlt.initscript[n_initscript] = strdup(*nextArg); >+ if (newAlt.initscript[n_initscript] == NULL) >+ return 1; >+ newAlt.initscript[n_initscript + 1] = NULL; >+ n_initscript++; > nextArg++; > } else if (!strcmp(*nextArg, "--remove")) { > setupDoubleArg(&mode, &nextArg, MODE_REMOVE, &title, &target);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 756390
: 699917