diff options
author | jp151216 <none@none> | 2008-01-25 07:24:38 -0800 |
---|---|---|
committer | jp151216 <none@none> | 2008-01-25 07:24:38 -0800 |
commit | 4edd44c51fec55142bfb7fb1ee7aaa13a910a80f (patch) | |
tree | be79bf142eeb533e8af6d3cbc02956ec3a8a49f4 /usr/src | |
parent | 42ee8d7158e705b1ccd458125f49e90bbac23703 (diff) | |
download | illumos-joyent-4edd44c51fec55142bfb7fb1ee7aaa13a910a80f.tar.gz |
6648709 valid_ephemeral_uid/gid() incorrectly test for the reserved emphemeral ID range
6652155 idmap c-style hides cstyle problems
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/idmap/idmap/idmap_engine.c | 16 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/adutils.c | 10 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/idmap_config.c | 37 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/idmapd.c | 39 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/init.c | 32 | ||||
-rw-r--r-- | usr/src/lib/libidmap/common/utils.c | 36 | ||||
-rw-r--r-- | usr/src/uts/common/os/cred.c | 4 |
7 files changed, 100 insertions, 74 deletions
diff --git a/usr/src/cmd/idmap/idmap/idmap_engine.c b/usr/src/cmd/idmap/idmap/idmap_engine.c index 3b9ddf22a9..295e955479 100644 --- a/usr/src/cmd/idmap/idmap/idmap_engine.c +++ b/usr/src/cmd/idmap/idmap/idmap_engine.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -112,7 +112,8 @@ options_clean() /* determine which subcommand is argv[0] and execute its handler */ static int -run_command(int argc, char **argv, cmd_pos_t *pos) { +run_command(int argc, char **argv, cmd_pos_t *pos) +{ int i; if (argc == 0) { @@ -154,7 +155,8 @@ run_command(int argc, char **argv, cmd_pos_t *pos) { * is quoted). Duplicate it to "to". Remove quotation, if any. */ static int -get_param(char **to, const char *from) { +get_param(char **to, const char *from) +{ int to_i, from_i; char c; int last_slash = 0; /* Preceded by a slash? */ @@ -501,7 +503,8 @@ source_interp(const char *name) int engine_init(int comc, cmd_ops_t *comv, int argc, char **argv, - int *is_batch_mode) { + int *is_batch_mode) +{ int c; my_comc = comc; @@ -529,7 +532,7 @@ engine_init(int comc, cmd_ops_t *comv, int argc, char **argv, optind = 0; while ((c = getopt(argc, argv, - "f:(command-file)")) != EOF) { + "f:(command-file)")) != EOF) { switch (c) { case '?': return (IDMAP_ENG_ERROR); @@ -552,7 +555,8 @@ the_end: /* finitialize the engine */ int -engine_fini() { +engine_fini() +{ my_argv_clean(); free(my_argv); return (0); diff --git a/usr/src/cmd/idmap/idmapd/adutils.c b/usr/src/cmd/idmap/idmapd/adutils.c index 077d934129..5f275dcc64 100644 --- a/usr/src/cmd/idmap/idmapd/adutils.c +++ b/usr/src/cmd/idmap/idmapd/adutils.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -177,7 +177,8 @@ delete_ds(ad_t *ad, const char *host, int port); /*ARGSUSED*/ static int -idmap_saslcallback(LDAP *ld, unsigned flags, void *defaults, void *prompts) { +idmap_saslcallback(LDAP *ld, unsigned flags, void *defaults, void *prompts) +{ sasl_interact_t *interact; if (prompts == NULL || flags != LDAP_SASL_INTERACTIVE) @@ -185,7 +186,7 @@ idmap_saslcallback(LDAP *ld, unsigned flags, void *defaults, void *prompts) { /* There should be no extra arguemnts for SASL/GSSAPI authentication */ for (interact = prompts; interact->id != SASL_CB_LIST_END; - interact++) { + interact++) { interact->result = NULL; interact->len = 0; } @@ -1031,7 +1032,8 @@ idmap_lookup_batch_start(ad_t *ad, int nqueries, idmap_query_state_t **state) */ void idmap_lookup_batch_set_unixattr(idmap_query_state_t *state, - const char *unixuser_attr, const char *unixgroup_attr) { + const char *unixuser_attr, const char *unixgroup_attr) +{ state->ad_unixuser_attr = unixuser_attr; state->ad_unixgroup_attr = unixgroup_attr; } diff --git a/usr/src/cmd/idmap/idmapd/idmap_config.c b/usr/src/cmd/idmap/idmapd/idmap_config.c index 3273f80617..ccfef13f2e 100644 --- a/usr/src/cmd/idmap/idmapd/idmap_config.c +++ b/usr/src/cmd/idmap/idmapd/idmap_config.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -61,7 +61,8 @@ int hup_ev_port = -1; extern int hupped; static int -generate_machine_sid(char **machine_sid) { +generate_machine_sid(char **machine_sid) +{ char *p; uuid_t uu; int i, j, len, rlen; @@ -89,7 +90,7 @@ generate_machine_sid(char **machine_sid) { for (i = 0; i < UUID_LEN/4; i++) { j = i * 4; rid = (uu[j] << 24) | (uu[j + 1] << 16) | - (uu[j + 2] << 8) | (uu[j + 3]); + (uu[j + 2] << 8) | (uu[j + 3]); rlen = snprintf(p, len, "-%u", rid); p += rlen; len -= rlen; @@ -143,7 +144,8 @@ destruction: } static char * -scf_value2string(scf_value_t *value) { +scf_value2string(scf_value_t *value) +{ int rc = -1; char buf_size = 127; int length; @@ -167,8 +169,8 @@ scf_value2string(scf_value_t *value) { } } else { rc = 0; - break; - } + break; + } } destruction: @@ -1028,7 +1030,8 @@ exit: * Initialize 'cfg'. */ idmap_cfg_t * -idmap_cfg_init() { +idmap_cfg_init() +{ idmap_cfg_handles_t *handles; /* First the smf repository handles: */ @@ -1063,21 +1066,20 @@ idmap_cfg_init() { } if (scf_handle_decode_fmri(handles->main, - FMRI_BASE "/:properties/" CONFIG_PG, - NULL, /* scope */ - handles->service, /* service */ - handles->instance, /* instance */ - handles->config_pg, /* pg */ - NULL, /* prop */ - SCF_DECODE_FMRI_EXACT) < 0) { + FMRI_BASE "/:properties/" CONFIG_PG, + NULL, /* scope */ + handles->service, /* service */ + handles->instance, /* instance */ + handles->config_pg, /* pg */ + NULL, /* prop */ + SCF_DECODE_FMRI_EXACT) < 0) { idmapdlog(LOG_ERR, "%s: scf_handle_decode_fmri() failed: %s", me, scf_strerror(scf_error())); goto error; - } if (scf_service_get_pg(handles->service, - GENERAL_PG, handles->general_pg) < 0) { + GENERAL_PG, handles->general_pg) < 0) { idmapdlog(LOG_ERR, "%s: scf_service_get_pg() failed: %s", me, scf_strerror(scf_error())); goto error; @@ -1096,7 +1098,8 @@ error: } void -idmap_cfg_unload(idmap_pg_config_t *pgcfg) { +idmap_cfg_unload(idmap_pg_config_t *pgcfg) +{ if (pgcfg->default_domain) { free(pgcfg->default_domain); diff --git a/usr/src/cmd/idmap/idmapd/idmapd.c b/usr/src/cmd/idmap/idmapd/idmapd.c index b27c333fdb..b9e4791a22 100644 --- a/usr/src/cmd/idmap/idmapd/idmapd.c +++ b/usr/src/cmd/idmap/idmapd/idmapd.c @@ -114,7 +114,8 @@ app_krb5_user_uid(void) /*ARGSUSED*/ static void -hup_handler(int sig) { +hup_handler(int sig) +{ hupped = 1; if (hup_ev_port >= 0) (void) port_send(hup_ev_port, 1, &sig /* any ptr will do */); @@ -123,7 +124,8 @@ hup_handler(int sig) { /*ARGSUSED*/ static void -term_handler(int sig) { +term_handler(int sig) +{ (void) idmapdlog(LOG_INFO, "idmapd: Terminating."); fini_idmapd(); _exit(0); @@ -132,7 +134,8 @@ term_handler(int sig) { static int pipe_fd = -1; static void -daemonize_ready(void) { +daemonize_ready(void) +{ char data = '\0'; /* * wake the parent @@ -142,7 +145,8 @@ daemonize_ready(void) { } static int -daemonize_start(void) { +daemonize_start(void) +{ char data; int status; int devnull; @@ -258,7 +262,8 @@ main(int argc, char **argv) } static void -init_idmapd() { +init_idmapd() +{ int error; int connmaxrec = IDMAP_MAX_DOOR_RPC; @@ -279,24 +284,24 @@ init_idmapd() { memset(&_idmapdstate, 0, sizeof (_idmapdstate)); if (sysinfo(SI_HOSTNAME, _idmapdstate.hostname, - sizeof (_idmapdstate.hostname)) == -1) { + sizeof (_idmapdstate.hostname)) == -1) { error = errno; idmapdlog(LOG_ERR, - "idmapd: unable to determine hostname, error: %d", - error); + "idmapd: unable to determine hostname, error: %d", + error); exit(1); } if ((error = init_mapping_system()) < 0) { idmapdlog(LOG_ERR, - "idmapd: unable to initialize mapping system"); + "idmapd: unable to initialize mapping system"); exit(error < -2 ? SMF_EXIT_ERR_CONFIG : 1); } xprt = svc_door_create(idmap_prog_1, IDMAP_PROG, IDMAP_V1, connmaxrec); if (xprt == NULL) { idmapdlog(LOG_ERR, - "idmapd: unable to create door RPC service"); + "idmapd: unable to create door RPC service"); goto errout; } @@ -314,15 +319,15 @@ init_idmapd() { } if ((error = idmap_reg(dfd)) != 0) { idmapdlog(LOG_ERR, "idmapd: unable to register door (%s)", - strerror(errno)); + strerror(errno)); goto errout; } if ((error = allocids(_idmapdstate.new_eph_db, - 8192, &_idmapdstate.next_uid, - 8192, &_idmapdstate.next_gid)) != 0) { + 8192, &_idmapdstate.next_uid, + 8192, &_idmapdstate.next_gid)) != 0) { idmapdlog(LOG_ERR, "idmapd: unable to allocate ephemeral IDs " - "(%s)", strerror(errno)); + "(%s)", strerror(errno)); _idmapdstate.next_uid = _idmapdstate.limit_uid = SENTINEL_PID; _idmapdstate.next_gid = _idmapdstate.limit_gid = SENTINEL_PID; } else { @@ -340,7 +345,8 @@ errout: } static void -fini_idmapd() { +fini_idmapd() +{ idmap_unreg(dfd); fini_mapping_system(); if (xprt != NULL) @@ -348,7 +354,8 @@ fini_idmapd() { } void -idmapdlog(int pri, const char *format, ...) { +idmapdlog(int pri, const char *format, ...) +{ va_list args; va_start(args, format); diff --git a/usr/src/cmd/idmap/idmapd/init.c b/usr/src/cmd/idmap/idmapd/init.c index 0cbdf035df..ce116b83be 100644 --- a/usr/src/cmd/idmap/idmapd/init.c +++ b/usr/src/cmd/idmap/idmapd/init.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,7 +43,8 @@ static const char *me = "idmapd"; int -init_mapping_system() { +init_mapping_system() +{ int rc = 0; if (rwlock_init(&_idmapdstate.rwlk_cfg, USYNC_THREAD, NULL) != 0) @@ -64,12 +65,14 @@ init_mapping_system() { } void -fini_mapping_system() { +fini_mapping_system() +{ fini_dbs(); } int -load_config() { +load_config() +{ int rc; idmap_pg_config_t *pgcfg; if ((_idmapdstate.cfg = idmap_cfg_init()) == NULL) { @@ -92,7 +95,7 @@ load_config() { if (rc != 0) /* Partial failure */ idmapdlog(LOG_ERR, "%s: Various errors occurred while loading " - "the configuration; check the logs", me); + "the configuration; check the logs", me); if (pgcfg->global_catalog == NULL || pgcfg->global_catalog[0].host[0] == '\0') { @@ -110,7 +113,7 @@ load_config() { if (idmap_cfg_start_updates(_idmapdstate.cfg) < 0) idmapdlog(LOG_ERR, "%s: could not start config updater", - me); + me); idmapdlog(LOG_DEBUG, "%s: initial configuration loaded", me); @@ -119,7 +122,8 @@ load_config() { int -reload_ad() { +reload_ad() +{ int i; ad_t *old; ad_t *new; @@ -168,7 +172,8 @@ reload_ad() { void -print_idmapdstate() { +print_idmapdstate() +{ int i; idmap_pg_config_t *pgcfg; @@ -226,20 +231,21 @@ print_idmapdstate() { } int -create_directory(const char *path, uid_t uid, gid_t gid) { +create_directory(const char *path, uid_t uid, gid_t gid) +{ int rc; if ((rc = mkdir(path, 0700)) < 0 && errno != EEXIST) { idmapdlog(LOG_ERR, - "%s: Error creating directory %s (%s)", - me, path, strerror(errno)); + "%s: Error creating directory %s (%s)", + me, path, strerror(errno)); return (-1); } if (lchown(path, uid, gid) < 0) { idmapdlog(LOG_ERR, - "%s: Error creating directory %s (%s)", - me, path, strerror(errno)); + "%s: Error creating directory %s (%s)", + me, path, strerror(errno)); if (rc == 0) (void) rmdir(path); return (-1); diff --git a/usr/src/lib/libidmap/common/utils.c b/usr/src/lib/libidmap/common/utils.c index 80b9141c47..1c073b75d6 100644 --- a/usr/src/lib/libidmap/common/utils.c +++ b/usr/src/lib/libidmap/common/utils.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -42,31 +42,33 @@ static struct timeval TIMEOUT = { 25, 0 }; idmap_retcode -_udt_extend_batch(idmap_udt_handle_t *udthandle) { +_udt_extend_batch(idmap_udt_handle_t *udthandle) +{ idmap_update_op *tmplist; size_t nsize; if (udthandle->next >= udthandle->batch.idmap_update_batch_len) { nsize = (udthandle->batch.idmap_update_batch_len + - _UDT_SIZE_INCR) * sizeof (*tmplist); + _UDT_SIZE_INCR) * sizeof (*tmplist); tmplist = realloc( - udthandle->batch.idmap_update_batch_val, nsize); + udthandle->batch.idmap_update_batch_val, nsize); if (tmplist == NULL) return (IDMAP_ERR_MEMORY); (void) memset((uchar_t *)tmplist + - (udthandle->batch.idmap_update_batch_len * - sizeof (*tmplist)), 0, - _UDT_SIZE_INCR * sizeof (*tmplist)); + (udthandle->batch.idmap_update_batch_len * + sizeof (*tmplist)), 0, + _UDT_SIZE_INCR * sizeof (*tmplist)); udthandle->batch.idmap_update_batch_val = tmplist; udthandle->batch.idmap_update_batch_len += _UDT_SIZE_INCR; } udthandle->batch.idmap_update_batch_val[udthandle->next].opnum = - OP_NONE; + OP_NONE; return (IDMAP_SUCCESS); } idmap_retcode -_get_ids_extend_batch(idmap_get_handle_t *gh) { +_get_ids_extend_batch(idmap_get_handle_t *gh) +{ idmap_mapping *t1; idmap_get_res_t *t2; size_t nsize, len; @@ -79,7 +81,7 @@ _get_ids_extend_batch(idmap_get_handle_t *gh) { if (t1 == NULL) return (IDMAP_ERR_MEMORY); (void) memset((uchar_t *)t1 + (len * sizeof (*t1)), 0, - _GET_IDS_SIZE_INCR * sizeof (*t1)); + _GET_IDS_SIZE_INCR * sizeof (*t1)); gh->batch.idmap_mapping_batch_val = t1; /* extend the return list */ @@ -88,7 +90,7 @@ _get_ids_extend_batch(idmap_get_handle_t *gh) { if (t2 == NULL) return (IDMAP_ERR_MEMORY); (void) memset((uchar_t *)t2 + (len * sizeof (*t2)), 0, - _GET_IDS_SIZE_INCR * sizeof (*t2)); + _GET_IDS_SIZE_INCR * sizeof (*t2)); gh->retlist = t2; gh->batch.idmap_mapping_batch_len += _GET_IDS_SIZE_INCR; @@ -99,7 +101,8 @@ _get_ids_extend_batch(idmap_get_handle_t *gh) { idmap_stat _iter_get_next_list(int type, idmap_iter_t *iter, void *arg, uchar_t **list, size_t valsize, - xdrproc_t xdr_arg_proc, xdrproc_t xdr_res_proc) { + xdrproc_t xdr_arg_proc, xdrproc_t xdr_res_proc) +{ CLIENT *clnt; enum clnt_stat clntstat; @@ -120,9 +123,9 @@ _iter_get_next_list(int type, idmap_iter_t *iter, (void) memset(*list, 0, valsize); clntstat = clnt_call(clnt, type, - xdr_arg_proc, (caddr_t)arg, - xdr_res_proc, (caddr_t)*list, - TIMEOUT); + xdr_arg_proc, (caddr_t)arg, + xdr_res_proc, (caddr_t)*list, + TIMEOUT); if (clntstat != RPC_SUCCESS) { free(*list); return (_idmap_rpc2stat(clnt)); @@ -132,7 +135,8 @@ _iter_get_next_list(int type, idmap_iter_t *iter, } idmap_stat -_idmap_rpc2stat(CLIENT *clnt) { +_idmap_rpc2stat(CLIENT *clnt) +{ /* * We only deal with door_call(3C) errors here. We look at * r_err.re_errno instead of r_err.re_status because we need diff --git a/usr/src/uts/common/os/cred.c b/usr/src/uts/common/os/cred.c index 9102e0b627..7b3709de38 100644 --- a/usr/src/uts/common/os/cred.c +++ b/usr/src/uts/common/os/cred.c @@ -1027,7 +1027,7 @@ boolean_t valid_ephemeral_uid(zone_t *zone, uid_t id) { ephemeral_zsd_t *eph_zsd; - if (id < IDMAP_WK__MAX_UID) + if (id <= IDMAP_WK__MAX_UID) return (B_TRUE); eph_zsd = get_ephemeral_zsd(zone); @@ -1040,7 +1040,7 @@ boolean_t valid_ephemeral_gid(zone_t *zone, gid_t id) { ephemeral_zsd_t *eph_zsd; - if (id < IDMAP_WK__MAX_GID) + if (id <= IDMAP_WK__MAX_GID) return (B_TRUE); eph_zsd = get_ephemeral_zsd(zone); |