ナビゲーションリンクをスキップ | |
印刷ビューの終了 | |
![]() |
Trusted Extensions 開発者ガイド Oracle Solaris 10 1/13 Information Library (日本語) |
1. Trusted Extensions API およびセキュリティーポリシー
9. Solaris Trusted Extensions ラベル API のための試験的な Java バインディング
このコード例は、このプログラムが動作しているゾーンの機密ラベルを取得し、出力する方法を示しています。
#include <tsol/label.h> main() { m_label_t* pl; char *plabel = NULL; int retval; /* allocate an m_label_t for the process sensitivity label */ pl = m_label_alloc(MAC_LABEL); /* get the process sensitivity label */ if ((retval = getplabel(pl)) != 0) { perror("getplabel(pl) failed"); exit(1); } /* Translate the process sensitivity label to text and print */ if ((retval = label_to_str(pl, &plabel, M_LABEL, LONG_NAMES)) != 0) { perror("label_to_str(M_LABEL, LONG_NAMES) failed"); exit(1); } printf("Process label = %s\n", plabel); /* free allocated memory */ m_label_free(pl); free(plabel); }
printf() 文は機密ラベルを出力します。機密ラベルは、プログラムが動作しているゾーンから継承されます。次に、このプログラム例のテキスト出力を示します。
Process label = ADMIN_LOW
テキスト出力は、label_encodings ファイルでの指定によって異なります。