diff options
author | Jordan Brown <Jordan.Brown@Sun.COM> | 2009-11-05 14:34:36 -0800 |
---|---|---|
committer | Jordan Brown <Jordan.Brown@Sun.COM> | 2009-11-05 14:34:36 -0800 |
commit | bbf6f00c25b6a2bed23c35eac6d62998ecdb338c (patch) | |
tree | 8cf72fd47362b5b0da2ffe9be7fe7726a3d24426 /usr/src/cmd/idmap | |
parent | d95ac3ffcdcc13296bb4c53f621f72c0535f32c3 (diff) | |
download | illumos-joyent-bbf6f00c25b6a2bed23c35eac6d62998ecdb338c.tar.gz |
6747532 ns_lookup_bypid spams syslog with too many messages
6888836 Not listing all files in a directory of a CIFS share in Windows XP
6812570 Trans2 is missing pass-through levels: FILE_RENAME_INFORMATION (and others)
6888827 Add Unicode codepage support
6865488 libadutils: leak in ldap_lookup_domains_in_forest()
6888708 idmapd crashing periodically. Need cores analyzed.
6891342 invalid, redundant SQL in rule WHERE expressions
6891767 minor cleanups in idmap
6892544 Panic occurred at smb_node_ref+0x7f(ffffffd612297310)
--HG--
rename : usr/src/uts/common/smbsrv/cifs.h => usr/src/uts/common/smbsrv/smb.h
Diffstat (limited to 'usr/src/cmd/idmap')
-rw-r--r-- | usr/src/cmd/idmap/idmapd/dbutils.c | 67 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/idmapd.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/idmap/idmapd/server.c | 27 |
3 files changed, 34 insertions, 64 deletions
diff --git a/usr/src/cmd/idmap/idmapd/dbutils.c b/usr/src/cmd/idmap/idmapd/dbutils.c index aed92d22ed..b927461d6d 100644 --- a/usr/src/cmd/idmap/idmapd/dbutils.c +++ b/usr/src/cmd/idmap/idmapd/dbutils.c @@ -602,6 +602,7 @@ gen_sql_expr_from_rule(idmap_namerule *rule, char **out) { char *s_windomain = NULL, *s_winname = NULL; char *s_unixname = NULL; + char *dir; char *lower_winname; int retcode = IDMAP_SUCCESS; @@ -642,10 +643,28 @@ gen_sql_expr_from_rule(idmap_namerule *rule, char **out) } } - *out = sqlite_mprintf("%s %s %s", + switch (rule->direction) { + case IDMAP_DIRECTION_BI: + dir = "AND w2u_order > 0 AND u2w_order > 0"; + break; + case IDMAP_DIRECTION_W2U: + dir = "AND w2u_order > 0" + " AND (u2w_order = 0 OR u2w_order ISNULL)"; + break; + case IDMAP_DIRECTION_U2W: + dir = "AND u2w_order > 0" + " AND (w2u_order = 0 OR w2u_order ISNULL)"; + break; + default: + dir = ""; + break; + } + + *out = sqlite_mprintf("%s %s %s %s", s_windomain ? s_windomain : "", s_winname ? s_winname : "", - s_unixname ? s_unixname : ""); + s_unixname ? s_unixname : "", + dir); if (*out == NULL) { retcode = IDMAP_ERR_MEMORY; @@ -945,31 +964,17 @@ rm_namerule(sqlite *db, idmap_namerule *rule) { char *sql = NULL; idmap_stat retcode; - char buf[80]; char *expr = NULL; if (rule->direction < 0 && EMPTY_STRING(rule->windomain) && EMPTY_STRING(rule->winname) && EMPTY_STRING(rule->unixname)) return (IDMAP_SUCCESS); - buf[0] = 0; - - if (rule->direction == IDMAP_DIRECTION_BI) - (void) snprintf(buf, sizeof (buf), "AND w2u_order > 0" - " AND u2w_order > 0"); - else if (rule->direction == IDMAP_DIRECTION_W2U) - (void) snprintf(buf, sizeof (buf), "AND w2u_order > 0" - " AND (u2w_order = 0 OR u2w_order ISNULL)"); - else if (rule->direction == IDMAP_DIRECTION_U2W) - (void) snprintf(buf, sizeof (buf), "AND u2w_order > 0" - " AND (w2u_order = 0 OR w2u_order ISNULL)"); - retcode = gen_sql_expr_from_rule(rule, &expr); if (retcode != IDMAP_SUCCESS) goto out; - sql = sqlite_mprintf("DELETE FROM namerules WHERE 1 %s %s;", expr, - buf); + sql = sqlite_mprintf("DELETE FROM namerules WHERE 1 %s;", expr); if (sql == NULL) { retcode = IDMAP_ERR_INTERNAL; @@ -2683,8 +2688,6 @@ ns_lookup_byname(const char *name, const char *lower_name, idmap_id *id) struct passwd pwd, *pwdp; struct group grp, *grpp; char *buf; - int errnum; - const char *me = "ns_lookup_byname"; static size_t pwdbufsiz = 0; static size_t grpbufsiz = 0; @@ -2698,11 +2701,7 @@ ns_lookup_byname(const char *name, const char *lower_name, idmap_id *id) name != lower_name && strcmp(name, lower_name) != 0) pwdp = getpwnam_r(lower_name, &pwd, buf, pwdbufsiz); if (pwdp == NULL) { - errnum = errno; - idmapdlog(LOG_WARNING, - "%s: getpwnam_r(%s) failed (%s).", - me, name, errnum ? strerror(errnum) : "not found"); - if (errnum == 0) + if (errno == 0) return (IDMAP_ERR_NOTFOUND); else return (IDMAP_ERR_INTERNAL); @@ -2718,11 +2717,7 @@ ns_lookup_byname(const char *name, const char *lower_name, idmap_id *id) name != lower_name && strcmp(name, lower_name) != 0) grpp = getgrnam_r(lower_name, &grp, buf, grpbufsiz); if (grpp == NULL) { - errnum = errno; - idmapdlog(LOG_WARNING, - "%s: getgrnam_r(%s) failed (%s).", - me, name, errnum ? strerror(errnum) : "not found"); - if (errnum == 0) + if (errno == 0) return (IDMAP_ERR_NOTFOUND); else return (IDMAP_ERR_INTERNAL); @@ -2746,8 +2741,6 @@ ns_lookup_bypid(uid_t pid, int is_user, char **unixname) struct passwd pwd; struct group grp; char *buf; - int errnum; - const char *me = "ns_lookup_bypid"; static size_t pwdbufsiz = 0; static size_t grpbufsiz = 0; @@ -2757,11 +2750,7 @@ ns_lookup_bypid(uid_t pid, int is_user, char **unixname) buf = alloca(pwdbufsiz); errno = 0; if (getpwuid_r(pid, &pwd, buf, pwdbufsiz) == NULL) { - errnum = errno; - idmapdlog(LOG_WARNING, - "%s: getpwuid_r(%u) failed (%s).", - me, pid, errnum ? strerror(errnum) : "not found"); - if (errnum == 0) + if (errno == 0) return (IDMAP_ERR_NOTFOUND); else return (IDMAP_ERR_INTERNAL); @@ -2773,11 +2762,7 @@ ns_lookup_bypid(uid_t pid, int is_user, char **unixname) buf = alloca(grpbufsiz); errno = 0; if (getgrgid_r(pid, &grp, buf, grpbufsiz) == NULL) { - errnum = errno; - idmapdlog(LOG_WARNING, - "%s: getgrgid_r(%u) failed (%s).", - me, pid, errnum ? strerror(errnum) : "not found"); - if (errnum == 0) + if (errno == 0) return (IDMAP_ERR_NOTFOUND); else return (IDMAP_ERR_INTERNAL); diff --git a/usr/src/cmd/idmap/idmapd/idmapd.c b/usr/src/cmd/idmap/idmapd/idmapd.c index 0fb05067b9..aea2fcc634 100644 --- a/usr/src/cmd/idmap/idmapd/idmapd.c +++ b/usr/src/cmd/idmap/idmapd/idmapd.c @@ -282,9 +282,9 @@ main(int argc, char **argv) _idmapdstate.daemon_mode = FALSE; break; default: - fprintf(stderr, "Usage: /usr/lib/idmapd"); + (void) fprintf(stderr, + "Usage: /usr/lib/idmapd [-d]\n"); return (SMF_EXIT_ERR_CONFIG); - break; } } diff --git a/usr/src/cmd/idmap/idmapd/server.c b/usr/src/cmd/idmap/idmapd/server.c index 8c26069a9f..59d53a2a98 100644 --- a/usr/src/cmd/idmap/idmapd/server.c +++ b/usr/src/cmd/idmap/idmapd/server.c @@ -560,7 +560,6 @@ idmap_list_mappings_1_svc(int64_t lastrowid, uint64_t limit, int32_t flag, time_t curtime; (void) memset(result, 0, sizeof (*result)); - lbuf[0] = rbuf[0] = 0; /* Current time */ errno = 0; @@ -588,6 +587,8 @@ idmap_list_mappings_1_svc(int64_t lastrowid, uint64_t limit, int32_t flag, if (limit > 0) (void) snprintf(lbuf, sizeof (lbuf), "LIMIT %" PRIu64, limit + 1ULL); + else + lbuf[0] = '\0'; (void) snprintf(rbuf, sizeof (rbuf), "rowid > %" PRIu64, lastrowid); @@ -704,7 +705,6 @@ idmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid, { sqlite *db = NULL; - char w2ubuf[15], u2wbuf[15]; char lbuf[30], rbuf[30]; char *sql = NULL; char *expr = NULL; @@ -712,7 +712,6 @@ idmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid, idmap_retcode retcode; (void) memset(result, 0, sizeof (*result)); - lbuf[0] = rbuf[0] = 0; result->retcode = validate_rule(&rule); if (result->retcode != IDMAP_SUCCESS) @@ -727,22 +726,6 @@ idmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid, if (result->retcode != IDMAP_SUCCESS) goto out; - result->retcode = IDMAP_ERR_INTERNAL; - - w2ubuf[0] = u2wbuf[0] = 0; - if (rule.direction == IDMAP_DIRECTION_BI) { - (void) snprintf(w2ubuf, sizeof (w2ubuf), "AND w2u_order > 0"); - (void) snprintf(u2wbuf, sizeof (u2wbuf), "AND u2w_order > 0"); - } else if (rule.direction == IDMAP_DIRECTION_W2U) { - (void) snprintf(w2ubuf, sizeof (w2ubuf), "AND w2u_order > 0"); - (void) snprintf(u2wbuf, sizeof (u2wbuf), - "AND (u2w_order = 0 OR u2w_order ISNULL)"); - } else if (rule.direction == IDMAP_DIRECTION_U2W) { - (void) snprintf(w2ubuf, sizeof (w2ubuf), - "AND (w2u_order = 0 OR w2u_order ISNULL)"); - (void) snprintf(u2wbuf, sizeof (u2wbuf), "AND u2w_order > 0"); - } - result->retcode = gen_sql_expr_from_rule(&rule, &expr); if (result->retcode != IDMAP_SUCCESS) goto out; @@ -753,6 +736,8 @@ idmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid, if (limit > 0) (void) snprintf(lbuf, sizeof (lbuf), "LIMIT %" PRIu64, limit + 1ULL); + else + lbuf[0] = '\0'; (void) snprintf(rbuf, sizeof (rbuf), "rowid > %" PRIu64, lastrowid); @@ -763,8 +748,8 @@ idmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid, sql = sqlite_mprintf("SELECT rowid, is_user, is_wuser, windomain, " "winname_display, is_nt4, unixname, w2u_order, u2w_order " "FROM namerules WHERE " - " %s %s %s %s %s;", - rbuf, expr, w2ubuf, u2wbuf, lbuf); + " %s %s %s;", + rbuf, expr, lbuf); if (sql == NULL) { result->retcode = IDMAP_ERR_MEMORY; |