label/label_selinux.go
func InitLabels(options []string) (string, string, error) {
	if !selinux.SelinuxEnabled() {
		return "", "", nil
	}
	processLabel, mountLabel := selinux.GetLxcContexts()
	if processLabel != "" {
		pcon := selinux.NewContext(processLabel)
		mcon := selinux.NewContext(mountLabel)
		for _, opt := range options {
			if opt == "disable" {
				return "", "", nil
			}
			if i := strings.Index(opt, ":"); i == -1 {
				return "", "", fmt.Errorf("Bad SELinux Option")
			}
			con := strings.SplitN(opt, ":", 2)
			pcon[con[0]] = con[1]
			if con[0] == "level" || con[0] == "user" {
				mcon[con[0]] = con[1]
			}
		}
		processLabel = pcon.Get()
		mountLabel = mcon.Get()
	}
	return processLabel, mountLabel, nil
}
func InitLabels(options []string) (string, string, error) {
	if !selinux.SelinuxEnabled() {
		return "", "", nil
	}
	processLabel, mountLabel := selinux.GetLxcContexts()
	if processLabel != "" {
		pcon := selinux.NewContext(processLabel)
		mcon := selinux.NewContext(mountLabel)
		for _, opt := range options {
			if opt == "disable" {
				return "", "", nil
			}
			if i := strings.Index(opt, ":"); i == -1 {
				return "", "", fmt.Errorf("Bad SELinux Option")
			}
			con := strings.SplitN(opt, ":", 2)
			pcon[con[0]] = con[1]
			if con[0] == "level" || con[0] == "user" {
				mcon[con[0]] = con[1]
			}
		}
		processLabel = pcon.Get()
		mountLabel = mcon.Get()
	}
	return processLabel, mountLabel, nil
}
func InitLabels ( options [ ] string ) ( string , string , error ) { if ! selinux . SelinuxEnabled ( ) { return " " , " " , nil } processLabel , mountLabel := selinux . GetLxcContexts ( ) if processLabel != " " { pcon := selinux . NewContext ( processLabel ) mcon := selinux . NewContext ( mountLabel ) for _ , opt := range options { if opt == " " { return " " , " " , nil } if i := strings . Index ( opt , " " ) ; i == - 1 { return " " , " " , fmt . Errorf ( " " ) } con := strings . SplitN ( opt , " " , 2 ) pcon [ con [ 0 ] ] = con [ 1 ] if con [ 0 ] == " " || con [ 0 ] == " " { mcon [ con [ 0 ] ] = con [ 1 ] } } processLabel = pcon . Get ( ) mountLabel = mcon . Get ( ) } return processLabel , mountLabel , nil }
// InitLabels returns the process label and file labels to be used within
// the container.  A list of options can be passed into this function to alter
// the labels.  The labels returned will include a random MCS String, that is
// guaranteed to be unique.
InitLabels returns the process label and file labels to be used within the container . A list of options can be passed into this function to alter the labels . The labels returned will include a random MCS String that is guaranteed to be unique .