Created
July 4, 2012 01:18
-
-
Save jclulow/3044557 to your computer and use it in GitHub Desktop.
user/group/privs for smfgen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/smfgen b/smfgen | |
| index 20560e8..ac47cdf 100755 | |
| --- a/smfgen | |
| +++ b/smfgen | |
| @@ -23,7 +23,7 @@ var header_comment = [ | |
| * identifier (FMRI) will be constructed from the category | |
| * and identifier. | |
| * | |
| - * [category] Service category (default: "application"). | |
| + * [category] Service category (default: "site"). | |
| * | |
| * label The human-readable name of the service. | |
| * | |
| @@ -37,6 +37,12 @@ var header_comment = [ | |
| * doesn't know when the service has actually started. | |
| * | |
| * [stop] Script that stops this service. | |
| + * | |
| + * [user] The user to run the start/stop methods as. | |
| + * | |
| + * [group] The group to run the start/stop methods as. | |
| + * | |
| + * [privileges] The RBAC privileges to run the start/stop methods with. | |
| */ | |
| function emitManifest(stream, conf) | |
| { | |
| @@ -77,7 +83,7 @@ function emitManifest(stream, conf) | |
| '"category" must be a string'); | |
| fmri = conf['category'] + '/' + conf['ident']; | |
| } else { | |
| - fmri = 'application/' + conf['ident']; | |
| + fmri = 'site/' + conf['ident']; | |
| } | |
| if (!conf.timeout) | |
| @@ -114,19 +120,45 @@ function emitManifest(stream, conf) | |
| xml.emitEnd('dependency'); | |
| }); | |
| - xml.emitEmpty('exec_method', { | |
| + xml.emitStart('exec_method', { | |
| 'type': 'method', | |
| 'name': 'start', | |
| 'exec': conf['start'] + ' &', | |
| 'timeout_seconds': conf.timeout.start || 10 | |
| }); | |
| + if (conf.user || conf.group || conf.privileges) { | |
| + var k = {}; | |
| + if (conf.user) | |
| + k.user = conf.user; | |
| + if (conf.group) | |
| + k.group = conf.group; | |
| + if (conf.privileges) | |
| + k.privileges = conf.privileges; | |
| + xml.emitStart('method_context'); | |
| + xml.emitEmpty('method_credential', k); | |
| + xml.emitEnd('method_context'); | |
| + } | |
| + xml.emitEnd('exec_method'); | |
| - xml.emitEmpty('exec_method', { | |
| + xml.emitStart('exec_method', { | |
| 'type': 'method', | |
| 'name': 'stop', | |
| 'exec': stop, | |
| 'timeout_seconds': conf.timeout.stop || 30 | |
| }); | |
| + if (conf.user || conf.group || conf.privileges) { | |
| + var k = {}; | |
| + if (conf.user) | |
| + k.user = conf.user; | |
| + if (conf.group) | |
| + k.group = conf.group; | |
| + if (conf.privileges) | |
| + k.privileges = conf.privileges; | |
| + xml.emitStart('method_context'); | |
| + xml.emitEmpty('method_credential', k); | |
| + xml.emitEnd('method_context'); | |
| + } | |
| + xml.emitEnd('exec_method'); | |
| xml.emitStart('template'); | |
| xml.emitStart('common_name'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment