func UserWithPtyInDatabase(utmpPath string, username string) error {
	if len(username) > userMaxLen {
		return trace.BadParameter("username length exceeds OS limits")
	}

	// Convert Go strings into C strings that we can pass over ffi.
	var cUtmpPath *C.char = nil
	if len(utmpPath) > 0 {
		cUtmpPath = C.CString(utmpPath)
		defer C.free(unsafe.Pointer(cUtmpPath))
	}
	cUsername := C.CString(username)
	defer C.free(unsafe.Pointer(cUsername))

	accountDb.Lock()
	status := C.uacc_has_entry_with_user(cUtmpPath, cUsername)
	accountDb.Unlock()

	switch status {
	case C.UACC_UTMP_FAILED_OPEN:
		code := C.get_errno()
		return trace.AccessDenied("failed to open user account database, code: %d", code)
	case C.UACC_UTMP_ENTRY_DOES_NOT_EXIST:
		return trace.NotFound("user not found")
	case C.UACC_UTMP_FAILED_TO_SELECT_FILE:
		return trace.BadParameter("failed to select file")
	case C.UACC_UTMP_PATH_DOES_NOT_EXIST:
		return trace.NotFound("user accounting files are missing from the system, running in a container?")
	default:
		if status != 0 {
			return trace.Errorf("unknown error with code %d", status)
		}

		return nil
	}
}
// UserWithPtyInDatabase checks the user accounting database for the existence of an USER_PROCESS entry with the given username.
UserWithPtyInDatabase checks the user accounting database for the existence of an USER_PROCESS entry with the given username.
// UserWithPtyInDatabase checks the user accounting database for the existence of an USER_PROCESS entry with the given username .
func UserWithPtyInDatabase(utmpPath string, username string) error {
	if len(username) > userMaxLen {
		return trace.BadParameter("username length exceeds OS limits")
	}
	var cUtmpPath *C.char = nil
	if len(utmpPath) > 0 {
		cUtmpPath = C.CString(utmpPath)
		defer C.free(unsafe.Pointer(cUtmpPath))
	}
	cUsername := C.CString(username)
	defer C.free(unsafe.Pointer(cUsername))
	accountDb.Lock()
	status := C.uacc_has_entry_with_user(cUtmpPath, cUsername)
	accountDb.Unlock()
	switch status {
	case C.UACC_UTMP_FAILED_OPEN:
		code := C.get_errno()
		return trace.AccessDenied("failed to open user account database, code: %d", code)
	case C.UACC_UTMP_ENTRY_DOES_NOT_EXIST:
		return trace.NotFound("user not found")
	case C.UACC_UTMP_FAILED_TO_SELECT_FILE:
		return trace.BadParameter("failed to select file")
	case C.UACC_UTMP_PATH_DOES_NOT_EXIST:
		return trace.NotFound("user accounting files are missing from the system, running in a container?")
	default:
		if status != 0 {
			return trace.Errorf("unknown error with code %d", status)
		}
		return nil
	}
}
func UserWithPtyInDatabase ( utmpPath string , username string ) error { if len ( username ) > userMaxLen { return trace . BadParameter ( " " ) } var cUtmpPath * C . char = nil if len ( utmpPath ) > 0 { cUtmpPath = C . CString ( utmpPath ) defer C . free ( unsafe . Pointer ( cUtmpPath ) ) } cUsername := C . CString ( username ) defer C . free ( unsafe . Pointer ( cUsername ) ) accountDb . Lock ( ) status := C . uacc_has_entry_with_user ( cUtmpPath , cUsername ) accountDb . Unlock ( ) switch status { case C . UACC_UTMP_FAILED_OPEN : code := C . get_errno ( ) return trace . AccessDenied ( " " , code ) case C . UACC_UTMP_ENTRY_DOES_NOT_EXIST : return trace . NotFound ( " " ) case C . UACC_UTMP_FAILED_TO_SELECT_FILE : return trace . BadParameter ( " " ) case C . UACC_UTMP_PATH_DOES_NOT_EXIST : return trace . NotFound ( " " ) default : if status != 0 { return trace . Errorf ( " " , status ) } return nil } }
UserWithPtyInDatabase checks the user accounting database for the existence of an USER_PROCESS entry with the given username.
UserWithPtyInDatabase checks the user accounting database for the existence of an USER_PROCESS entry with the given username .
// Convert Go strings into C strings that we can pass over ffi.