46 #include <libbrand_impl.h>
47 #include <libbrand.h>
48
49 #define DTD_ELEM_ATTACH ((const xmlChar *) "attach")
50 #define DTD_ELEM_BOOT ((const xmlChar *) "boot")
51 #define DTD_ELEM_BRAND ((const xmlChar *) "brand")
52 #define DTD_ELEM_CLONE ((const xmlChar *) "clone")
53 #define DTD_ELEM_COMMENT ((const xmlChar *) "comment")
54 #define DTD_ELEM_DETACH ((const xmlChar *) "detach")
55 #define DTD_ELEM_DEVICE ((const xmlChar *) "device")
56 #define DTD_ELEM_GLOBAL_MOUNT ((const xmlChar *) "global_mount")
57 #define DTD_ELEM_HALT ((const xmlChar *) "halt")
58 #define DTD_ELEM_INITNAME ((const xmlChar *) "initname")
59 #define DTD_ELEM_INSTALL ((const xmlChar *) "install")
60 #define DTD_ELEM_INSTALLOPTS ((const xmlChar *) "installopts")
61 #define DTD_ELEM_LOGIN_CMD ((const xmlChar *) "login_cmd")
62 #define DTD_ELEM_FORCELOGIN_CMD ((const xmlChar *) "forcedlogin_cmd")
63 #define DTD_ELEM_MODNAME ((const xmlChar *) "modname")
64 #define DTD_ELEM_MOUNT ((const xmlChar *) "mount")
65 #define DTD_ELEM_RESTARTINIT ((const xmlChar *) "restartinit")
66 #define DTD_ELEM_POSTATTACH ((const xmlChar *) "postattach")
67 #define DTD_ELEM_POSTCLONE ((const xmlChar *) "postclone")
68 #define DTD_ELEM_POSTINSTALL ((const xmlChar *) "postinstall")
69 #define DTD_ELEM_POSTSNAP ((const xmlChar *) "postsnap")
70 #define DTD_ELEM_POSTSTATECHG ((const xmlChar *) "poststatechange")
71 #define DTD_ELEM_PREDETACH ((const xmlChar *) "predetach")
72 #define DTD_ELEM_PRESNAP ((const xmlChar *) "presnap")
73 #define DTD_ELEM_PRESTATECHG ((const xmlChar *) "prestatechange")
74 #define DTD_ELEM_PREUNINSTALL ((const xmlChar *) "preuninstall")
75 #define DTD_ELEM_PRIVILEGE ((const xmlChar *) "privilege")
76 #define DTD_ELEM_QUERY ((const xmlChar *) "query")
77 #define DTD_ELEM_SHUTDOWN ((const xmlChar *) "shutdown")
78 #define DTD_ELEM_SYMLINK ((const xmlChar *) "symlink")
79 #define DTD_ELEM_SYSBOOT ((const xmlChar *) "sysboot")
80 #define DTD_ELEM_UNINSTALL ((const xmlChar *) "uninstall")
81 #define DTD_ELEM_USER_CMD ((const xmlChar *) "user_cmd")
82 #define DTD_ELEM_VALIDSNAP ((const xmlChar *) "validatesnap")
83 #define DTD_ELEM_VERIFY_CFG ((const xmlChar *) "verify_cfg")
84 #define DTD_ELEM_VERIFY_ADM ((const xmlChar *) "verify_adm")
85
513 buf, len, DTD_ELEM_HALT, B_TRUE, B_TRUE));
514 }
515
516 int
517 brand_get_shutdown(brand_handle_t bh, const char *zonename,
518 const char *zonepath, char *buf, size_t len)
519 {
520 struct brand_handle *bhp = (struct brand_handle *)bh;
521 return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
522 buf, len, DTD_ELEM_SHUTDOWN, B_TRUE, B_TRUE));
523 }
524
525 int
526 brand_get_initname(brand_handle_t bh, char *buf, size_t len)
527 {
528 struct brand_handle *bhp = (struct brand_handle *)bh;
529 return (brand_get_value(bhp, NULL, NULL, NULL, NULL,
530 buf, len, DTD_ELEM_INITNAME, B_FALSE, B_FALSE));
531 }
532
533 boolean_t
534 brand_restartinit(brand_handle_t bh)
535 {
536 struct brand_handle *bhp = (struct brand_handle *)bh;
537 char val[80];
538
539 if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
540 val, sizeof (val), DTD_ELEM_RESTARTINIT, B_FALSE, B_FALSE) != 0)
541 return (B_TRUE);
542
543 if (strcmp(val, "false") == 0)
544 return (B_FALSE);
545 return (B_TRUE);
546 }
547
548 int
549 brand_get_login_cmd(brand_handle_t bh, const char *username,
550 char *buf, size_t len)
551 {
552 struct brand_handle *bhp = (struct brand_handle *)bh;
553 const char *curr_zone = get_curr_zone();
554 return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
555 buf, len, DTD_ELEM_LOGIN_CMD, B_TRUE, B_FALSE));
556 }
557
558 int
559 brand_get_forcedlogin_cmd(brand_handle_t bh, const char *username,
560 char *buf, size_t len)
561 {
562 struct brand_handle *bhp = (struct brand_handle *)bh;
563 const char *curr_zone = get_curr_zone();
564 return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
565 buf, len, DTD_ELEM_FORCELOGIN_CMD, B_TRUE, B_FALSE));
566 }
567
|
46 #include <libbrand_impl.h>
47 #include <libbrand.h>
48
49 #define DTD_ELEM_ATTACH ((const xmlChar *) "attach")
50 #define DTD_ELEM_BOOT ((const xmlChar *) "boot")
51 #define DTD_ELEM_BRAND ((const xmlChar *) "brand")
52 #define DTD_ELEM_CLONE ((const xmlChar *) "clone")
53 #define DTD_ELEM_COMMENT ((const xmlChar *) "comment")
54 #define DTD_ELEM_DETACH ((const xmlChar *) "detach")
55 #define DTD_ELEM_DEVICE ((const xmlChar *) "device")
56 #define DTD_ELEM_GLOBAL_MOUNT ((const xmlChar *) "global_mount")
57 #define DTD_ELEM_HALT ((const xmlChar *) "halt")
58 #define DTD_ELEM_INITNAME ((const xmlChar *) "initname")
59 #define DTD_ELEM_INSTALL ((const xmlChar *) "install")
60 #define DTD_ELEM_INSTALLOPTS ((const xmlChar *) "installopts")
61 #define DTD_ELEM_LOGIN_CMD ((const xmlChar *) "login_cmd")
62 #define DTD_ELEM_FORCELOGIN_CMD ((const xmlChar *) "forcedlogin_cmd")
63 #define DTD_ELEM_MODNAME ((const xmlChar *) "modname")
64 #define DTD_ELEM_MOUNT ((const xmlChar *) "mount")
65 #define DTD_ELEM_RESTARTINIT ((const xmlChar *) "restartinit")
66 #define DTD_ELEM_RESTARTINIT0 ((const xmlChar *) "restartinit0")
67 #define DTD_ELEM_RESTARTINITREBOOT ((const xmlChar *) "restartinitreboot")
68 #define DTD_ELEM_POSTATTACH ((const xmlChar *) "postattach")
69 #define DTD_ELEM_POSTCLONE ((const xmlChar *) "postclone")
70 #define DTD_ELEM_POSTINSTALL ((const xmlChar *) "postinstall")
71 #define DTD_ELEM_POSTSNAP ((const xmlChar *) "postsnap")
72 #define DTD_ELEM_POSTSTATECHG ((const xmlChar *) "poststatechange")
73 #define DTD_ELEM_PREDETACH ((const xmlChar *) "predetach")
74 #define DTD_ELEM_PRESNAP ((const xmlChar *) "presnap")
75 #define DTD_ELEM_PRESTATECHG ((const xmlChar *) "prestatechange")
76 #define DTD_ELEM_PREUNINSTALL ((const xmlChar *) "preuninstall")
77 #define DTD_ELEM_PRIVILEGE ((const xmlChar *) "privilege")
78 #define DTD_ELEM_QUERY ((const xmlChar *) "query")
79 #define DTD_ELEM_SHUTDOWN ((const xmlChar *) "shutdown")
80 #define DTD_ELEM_SYMLINK ((const xmlChar *) "symlink")
81 #define DTD_ELEM_SYSBOOT ((const xmlChar *) "sysboot")
82 #define DTD_ELEM_UNINSTALL ((const xmlChar *) "uninstall")
83 #define DTD_ELEM_USER_CMD ((const xmlChar *) "user_cmd")
84 #define DTD_ELEM_VALIDSNAP ((const xmlChar *) "validatesnap")
85 #define DTD_ELEM_VERIFY_CFG ((const xmlChar *) "verify_cfg")
86 #define DTD_ELEM_VERIFY_ADM ((const xmlChar *) "verify_adm")
87
515 buf, len, DTD_ELEM_HALT, B_TRUE, B_TRUE));
516 }
517
518 int
519 brand_get_shutdown(brand_handle_t bh, const char *zonename,
520 const char *zonepath, char *buf, size_t len)
521 {
522 struct brand_handle *bhp = (struct brand_handle *)bh;
523 return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
524 buf, len, DTD_ELEM_SHUTDOWN, B_TRUE, B_TRUE));
525 }
526
527 int
528 brand_get_initname(brand_handle_t bh, char *buf, size_t len)
529 {
530 struct brand_handle *bhp = (struct brand_handle *)bh;
531 return (brand_get_value(bhp, NULL, NULL, NULL, NULL,
532 buf, len, DTD_ELEM_INITNAME, B_FALSE, B_FALSE));
533 }
534
535 static boolean_t
536 i_brand_restartinit(brand_handle_t bh, const xmlChar *tagname, boolean_t deflt)
537 {
538 struct brand_handle *bhp = (struct brand_handle *)bh;
539 char val[80];
540
541 if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
542 val, sizeof (val), tagname, B_FALSE, B_FALSE) != 0) {
543 return (deflt);
544 }
545
546 if (strcmp(val, "false") == 0)
547 return (B_FALSE);
548 return (B_TRUE);
549 }
550
551 boolean_t
552 brand_restartinit(brand_handle_t bh)
553 {
554 return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT, B_TRUE));
555 }
556
557 boolean_t
558 brand_restartinit0(brand_handle_t bh)
559 {
560 return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINIT0, B_FALSE));
561 }
562
563 boolean_t
564 brand_restartinitreboot(brand_handle_t bh)
565 {
566 return (i_brand_restartinit(bh, DTD_ELEM_RESTARTINITREBOOT, B_FALSE));
567 }
568
569 int
570 brand_get_login_cmd(brand_handle_t bh, const char *username,
571 char *buf, size_t len)
572 {
573 struct brand_handle *bhp = (struct brand_handle *)bh;
574 const char *curr_zone = get_curr_zone();
575 return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
576 buf, len, DTD_ELEM_LOGIN_CMD, B_TRUE, B_FALSE));
577 }
578
579 int
580 brand_get_forcedlogin_cmd(brand_handle_t bh, const char *username,
581 char *buf, size_t len)
582 {
583 struct brand_handle *bhp = (struct brand_handle *)bh;
584 const char *curr_zone = get_curr_zone();
585 return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
586 buf, len, DTD_ELEM_FORCELOGIN_CMD, B_TRUE, B_FALSE));
587 }
588
|