374         if ((str = smf_get_state(SMBD_DEFAULT_INSTANCE_FMRI)) != NULL) {
 375                 ret = (strcmp(str, SCF_STATE_STRING_MAINT) == 0);
 376                 free(str);
 377         }
 378         return (ret);
 379 }
 380 
 381 /*
 382  * smb_enable_share tells the implementation that it is to enable the share.
 383  * This entails converting the path and options into the appropriate ioctl
 384  * calls. It is assumed that all error checking of paths, etc. were
 385  * done earlier.
 386  */
 387 static int
 388 smb_enable_share(sa_share_t share)
 389 {
 390         char *path;
 391         smb_share_t si;
 392         sa_resource_t resource;
 393         boolean_t iszfs;
 394         boolean_t privileged;
 395         int err = SA_OK;
 396         priv_set_t *priv_effective;
 397         boolean_t online;
 398 
 399         /*
 400          * Don't support Trusted Extensions.
 401          */
 402         if (is_system_labeled()) {
 403                 (void) printf(dgettext(TEXT_DOMAIN,
 404                     "SMB: service not supported with Trusted Extensions\n"));
 405                 return (SA_NOT_SUPPORTED);
 406         }
 407 
 408         priv_effective = priv_allocset();
 409         (void) getppriv(PRIV_EFFECTIVE, priv_effective);
 410         privileged = (priv_isfullset(priv_effective) == B_TRUE);
 411         priv_freeset(priv_effective);
 412 
 413         /* get the path since it is important in several places */
 414         path = sa_get_share_attr(share, "path");
 415         if (path == NULL)
 416                 return (SA_NO_SUCH_PATH);
 417 
 418         /*
 419          * If administratively disabled, don't try to start anything.
 420          */
 421         online = smb_isonline();
 422         if (!online && !smb_isautoenable() && smb_isdisabled())
 423                 goto done;
 424 
 425         iszfs = sa_path_is_zfs(path);
 426 
 427         if (iszfs) {
 428 
 429                 if (privileged == B_FALSE && !online) {
 430 
 431                         if (!online) {
 432                                 (void) printf(dgettext(TEXT_DOMAIN,
 433                                     "SMB: Cannot share remove "
 434                                     "file system: %s\n"), path);
 435                                 (void) printf(dgettext(TEXT_DOMAIN,
 436                                     "SMB: Service needs to be enabled "
 437                                     "by a privileged user\n"));
 438                                 err = SA_NO_PERMISSION;
 439                                 errno = EPERM;
 440                         }
 441                         if (err) {
 442                                 sa_free_attr_string(path);
 443                                 return (err);
 444                         }
 445 
 446                 }
 447         }
 448 
 449         if (privileged == B_TRUE && !online) {
 450                 err = smb_enable_service();
 451                 if (err != SA_OK) {
 452                         (void) printf(dgettext(TEXT_DOMAIN,
 453                             "SMB: Unable to enable service\n"));
 454                 } else {
 455                         online = B_TRUE;
 456                 }
 457         }
 458 
 459         /*
 460          * Don't bother trying to start shares if the service isn't
 461          * running.
 462          */
 463         if (!online)
 464                 goto done;
 465 
 466         /* Each share can have multiple resources */
 467         for (resource = sa_get_share_resource(share, NULL);
 468             resource != NULL;
 469             resource = sa_get_next_resource(resource)) {
 
 | 
 
 
 374         if ((str = smf_get_state(SMBD_DEFAULT_INSTANCE_FMRI)) != NULL) {
 375                 ret = (strcmp(str, SCF_STATE_STRING_MAINT) == 0);
 376                 free(str);
 377         }
 378         return (ret);
 379 }
 380 
 381 /*
 382  * smb_enable_share tells the implementation that it is to enable the share.
 383  * This entails converting the path and options into the appropriate ioctl
 384  * calls. It is assumed that all error checking of paths, etc. were
 385  * done earlier.
 386  */
 387 static int
 388 smb_enable_share(sa_share_t share)
 389 {
 390         char *path;
 391         smb_share_t si;
 392         sa_resource_t resource;
 393         boolean_t iszfs;
 394         int err = SA_OK;
 395         boolean_t online;
 396 
 397         /*
 398          * Don't support Trusted Extensions.
 399          */
 400         if (is_system_labeled()) {
 401                 (void) printf(dgettext(TEXT_DOMAIN,
 402                     "SMB: service not supported with Trusted Extensions\n"));
 403                 return (SA_NOT_SUPPORTED);
 404         }
 405 
 406         /* get the path since it is important in several places */
 407         path = sa_get_share_attr(share, "path");
 408         if (path == NULL)
 409                 return (SA_NO_SUCH_PATH);
 410 
 411         /*
 412          * If administratively disabled, don't try to start anything.
 413          */
 414         online = smb_isonline();
 415         if (!online && !smb_isautoenable() && smb_isdisabled())
 416                 goto done;
 417 
 418         iszfs = sa_path_is_zfs(path);
 419 
 420         if (!online) {
 421                 err = smb_enable_service();
 422                 if (err != SA_OK) {
 423                         (void) printf(dgettext(TEXT_DOMAIN,
 424                             "SMB: Unable to enable service\n"));
 425                 } else {
 426                         online = B_TRUE;
 427                 }
 428         }
 429 
 430         /*
 431          * Don't bother trying to start shares if the service isn't
 432          * running.
 433          */
 434         if (!online)
 435                 goto done;
 436 
 437         /* Each share can have multiple resources */
 438         for (resource = sa_get_share_resource(share, NULL);
 439             resource != NULL;
 440             resource = sa_get_next_resource(resource)) {
 
 |