diff options
Diffstat (limited to 'usr/src/lib/libsmbfs')
-rw-r--r-- | usr/src/lib/libsmbfs/netsmb/smbfs_api.h | 4 | ||||
-rw-r--r-- | usr/src/lib/libsmbfs/smb/ctx.c | 27 | ||||
-rw-r--r-- | usr/src/lib/libsmbfs/smb/mapfile-vers | 2 | ||||
-rw-r--r-- | usr/src/lib/libsmbfs/smb/nb.c | 50 |
4 files changed, 68 insertions, 15 deletions
diff --git a/usr/src/lib/libsmbfs/netsmb/smbfs_api.h b/usr/src/lib/libsmbfs/netsmb/smbfs_api.h index b67543de1c..d89ac41207 100644 --- a/usr/src/lib/libsmbfs/netsmb/smbfs_api.h +++ b/usr/src/lib/libsmbfs/netsmb/smbfs_api.h @@ -120,8 +120,10 @@ int smb_ctx_get_tree(struct smb_ctx *); int smb_ctx_setauthflags(struct smb_ctx *, int); int smb_ctx_setcharset(struct smb_ctx *, const char *); -int smb_ctx_setflags(struct smb_ctx *, int, int, int); int smb_ctx_setfullserver(struct smb_ctx *, const char *); +int smb_ctx_setsigning(struct smb_ctx *, int ena, int req); + +int smb_ctx_setnbflags(struct smb_ctx *, int ena, int bcast); int smb_ctx_setscope(struct smb_ctx *, const char *); int smb_ctx_setwins(struct smb_ctx *, const char *, const char *); diff --git a/usr/src/lib/libsmbfs/smb/ctx.c b/usr/src/lib/libsmbfs/smb/ctx.c index 09b594cee0..04057ac334 100644 --- a/usr/src/lib/libsmbfs/smb/ctx.c +++ b/usr/src/lib/libsmbfs/smb/ctx.c @@ -852,6 +852,22 @@ smb_ctx_setsrvaddr(struct smb_ctx *ctx, const char *addr) return (0); } +/* + * API for library caller to set signing enabled, required + * Note: if not enable, ignore require + */ +int +smb_ctx_setsigning(struct smb_ctx *ctx, int enable, int require) +{ + ctx->ct_vopt &= ~SMBVOPT_SIGNING_MASK; + if (enable) { + ctx->ct_vopt |= SMBVOPT_SIGNING_ENABLED; + if (require) + ctx->ct_vopt |= SMBVOPT_SIGNING_REQUIRED; + } + return (0); +} + static int smb_parse_owner(char *pair, uid_t *uid, gid_t *gid) { @@ -1373,17 +1389,12 @@ smb_ctx_readrcsection(struct smb_ctx *ctx, const char *sname, int level) * "signing" was set in this section; override * the current signing settings. */ - ctx->ct_vopt &= ~SMBVOPT_SIGNING_MASK; if (strcmp(p, "disabled") == 0) { - /* leave flags zero (expr for lint) */ - (void) ctx->ct_vopt; + smb_ctx_setsigning(ctx, FALSE, FALSE); } else if (strcmp(p, "enabled") == 0) { - ctx->ct_vopt |= - SMBVOPT_SIGNING_ENABLED; + smb_ctx_setsigning(ctx, TRUE, FALSE); } else if (strcmp(p, "required") == 0) { - ctx->ct_vopt |= - SMBVOPT_SIGNING_ENABLED | - SMBVOPT_SIGNING_REQUIRED; + smb_ctx_setsigning(ctx, TRUE, TRUE); } else { /* * Unknown "signing" value. diff --git a/usr/src/lib/libsmbfs/smb/mapfile-vers b/usr/src/lib/libsmbfs/smb/mapfile-vers index e47b349b7f..4cf82af26b 100644 --- a/usr/src/lib/libsmbfs/smb/mapfile-vers +++ b/usr/src/lib/libsmbfs/smb/mapfile-vers @@ -80,11 +80,13 @@ SUNWprivate { smb_ctx_setauthflags; smb_ctx_setdomain; smb_ctx_setfullserver; + smb_ctx_setnbflags; smb_ctx_setpassword; smb_ctx_setpwhash; smb_ctx_setscope; smb_ctx_setserver; smb_ctx_setshare; + smb_ctx_setsigning; smb_ctx_setsrvaddr; smb_ctx_setuser; smb_ctx_setwins; diff --git a/usr/src/lib/libsmbfs/smb/nb.c b/usr/src/lib/libsmbfs/smb/nb.c index f280420c54..4957b88d2c 100644 --- a/usr/src/lib/libsmbfs/smb/nb.c +++ b/usr/src/lib/libsmbfs/smb/nb.c @@ -57,8 +57,25 @@ #include <netsmb/smb_lib.h> #include <netsmb/nb_lib.h> +void nb_ctx_setnbflags(struct nb_ctx *, int ns_ena, int bc_ena); int nb_ctx_setwins(struct nb_ctx *, const char *, const char *); +/* + * API for seting NetBIOS name lookup flags: + * NetBIOS name lookup enable, + * NetBIOS broadcast enable. + */ +int +smb_ctx_setnbflags(struct smb_ctx *ctx, int ns_ena, int bc_ena) +{ + struct nb_ctx *nb = ctx->ct_nb; + + if (nb == NULL) + return (EINVAL); + + nb_ctx_setnbflags(nb, ns_ena, bc_ena); + return (0); +} /* * API for library consumer to set wins1, wins2 @@ -113,6 +130,17 @@ nb_ctx_done(struct nb_ctx *ctx) free(ctx); } +void +nb_ctx_setnbflags(struct nb_ctx *nb, int ns_ena, int bc_ena) +{ + nb->nb_flags &= ~(NBCF_NS_ENABLE | NBCF_BC_ENABLE); + if (ns_ena) { + nb->nb_flags = NBCF_NS_ENABLE; + if (bc_ena) + nb->nb_flags = NBCF_BC_ENABLE; + } +} + int nb_ctx_setwins(struct nb_ctx *ctx, const char *wins1, const char *wins2) { @@ -250,12 +278,22 @@ nb_ctx_readrcsection(struct rcfile *rcfile, struct nb_ctx *ctx, return (error); } } - error = rc_getbool(rcfile, sname, "nbns_enable", &nbns_enable); - if (error == 0 && nbns_enable == 0) - ctx->nb_flags &= ~NBCF_NS_ENABLE; - error = rc_getbool(rcfile, sname, "nbns_broadcast", &nbns_broadcast); - if (error == 0 && nbns_broadcast == 0) - ctx->nb_flags &= ~NBCF_BC_ENABLE; + + /* + * Want to use nb_ctx_setnbflags here, but + * have to get both boolean values first, + * either from settings or defaults. + */ + nbns_enable = nbns_broadcast = -1; /* not set */ + rc_getbool(rcfile, sname, "nbns_enable", &nbns_enable); + rc_getbool(rcfile, sname, "nbns_broadcast", &nbns_broadcast); + if (nbns_enable >= 0 || nbns_broadcast >= 0) { + if (nbns_enable < 0) + nbns_enable = 1; /* default */ + if (nbns_broadcast < 0) + nbns_broadcast = 1; /* default */ + nb_ctx_setnbflags(ctx, nbns_enable, nbns_broadcast); + } return (0); } |