2009-03-03 09:44:41 +00:00
|
|
|
/*
|
2010-03-01 16:38:28 -07:00
|
|
|
* Copyright (C) 2008, 2010 Red Hat, Inc.
|
2009-03-03 09:44:41 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* James Morris <jmorris@namei.org>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef __VIR_SECURITY_H__
|
2010-03-09 19:22:22 +01:00
|
|
|
# define __VIR_SECURITY_H__
|
2009-03-03 09:44:41 +00:00
|
|
|
|
2010-03-09 19:22:22 +01:00
|
|
|
# include "internal.h"
|
|
|
|
# include "domain_conf.h"
|
2009-03-03 09:44:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return values for security driver probing: the driver will determine
|
|
|
|
* whether it should be enabled or disabled.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
SECURITY_DRIVER_ENABLE = 0,
|
|
|
|
SECURITY_DRIVER_ERROR = -1,
|
|
|
|
SECURITY_DRIVER_DISABLE = -2,
|
|
|
|
} virSecurityDriverStatus;
|
|
|
|
|
|
|
|
typedef struct _virSecurityDriver virSecurityDriver;
|
|
|
|
typedef virSecurityDriver *virSecurityDriverPtr;
|
2010-06-15 17:44:19 +01:00
|
|
|
|
|
|
|
typedef struct _virSecurityDriverState virSecurityDriverState;
|
|
|
|
typedef virSecurityDriverState *virSecurityDriverStatePtr;
|
|
|
|
|
2009-03-03 09:44:41 +00:00
|
|
|
typedef virSecurityDriverStatus (*virSecurityDriverProbe) (void);
|
2010-02-09 19:18:21 +00:00
|
|
|
typedef int (*virSecurityDriverOpen) (virSecurityDriverPtr drv);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainRestoreImageLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-03-17 11:35:40 +00:00
|
|
|
virDomainDiskDefPtr disk);
|
2010-05-27 16:44:47 +01:00
|
|
|
typedef int (*virSecurityDomainSetSocketLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm);
|
|
|
|
typedef int (*virSecurityDomainClearSocketLabel)(virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainSetImageLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-03-17 11:35:40 +00:00
|
|
|
virDomainDiskDefPtr disk);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainRestoreHostdevLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-08-14 14:23:11 +01:00
|
|
|
virDomainHostdevDefPtr dev);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainSetHostdevLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-08-14 14:23:11 +01:00
|
|
|
virDomainHostdevDefPtr dev);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainSetSavedStateLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-11-11 12:07:00 +00:00
|
|
|
const char *savefile);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainRestoreSavedStateLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2009-11-11 12:07:00 +00:00
|
|
|
const char *savefile);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainGenLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr sec);
|
|
|
|
typedef int (*virSecurityDomainReserveLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr sec);
|
|
|
|
typedef int (*virSecurityDomainReleaseLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr sec);
|
|
|
|
typedef int (*virSecurityDomainSetAllLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr sec,
|
2010-06-04 12:20:29 -04:00
|
|
|
const char *stdin_path);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainRestoreAllLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
Don't reset user/group/security label on shared filesystems during migrate
When QEMU runs with its disk on NFS, and as a non-root user, the
disk is chownd to that non-root user. When migration completes
the last step is shutting down the QEMU on the source host. THis
normally resets user/group/security label. This is bad when the
VM was just migrated because the file is still in use on the dest
host. It is thus neccessary to skip the reset step for any files
found to be on a shared filesystem
* src/libvirt_private.syms: Export virStorageFileIsSharedFS
* src/util/storage_file.c, src/util/storage_file.h: Add a new
method virStorageFileIsSharedFS() to determine if a file is
on a shared filesystem (NFS, GFS, OCFS2, etc)
* src/qemu/qemu_driver.c: Tell security driver not to reset
disk labels on migration completion
* src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
src/security/security_selinux.c, src/security/security_driver.h,
src/security/security_apparmor.c: Add ability to skip disk
restore step for files on shared filesystems.
2010-05-13 11:49:22 -04:00
|
|
|
int migrated);
|
2010-06-15 17:44:19 +01:00
|
|
|
typedef int (*virSecurityDomainGetProcessLabel) (virSecurityDriverPtr drv,
|
|
|
|
virDomainObjPtr vm,
|
2010-01-11 11:04:40 +00:00
|
|
|
virSecurityLabelPtr sec);
|
2010-02-09 19:18:21 +00:00
|
|
|
typedef int (*virSecurityDomainSetProcessLabel) (virSecurityDriverPtr drv,
|
2010-01-11 11:04:40 +00:00
|
|
|
virDomainObjPtr vm);
|
2010-02-09 19:18:21 +00:00
|
|
|
typedef int (*virSecurityDomainSecurityVerify) (virDomainDefPtr def);
|
2009-03-03 09:44:41 +00:00
|
|
|
|
|
|
|
struct _virSecurityDriver {
|
|
|
|
const char *name;
|
|
|
|
virSecurityDriverProbe probe;
|
|
|
|
virSecurityDriverOpen open;
|
2009-04-03 10:55:51 +00:00
|
|
|
virSecurityDomainSecurityVerify domainSecurityVerify;
|
2009-03-03 09:44:41 +00:00
|
|
|
virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
|
2010-05-27 16:44:47 +01:00
|
|
|
virSecurityDomainSetSocketLabel domainSetSecuritySocketLabel;
|
|
|
|
virSecurityDomainClearSocketLabel domainClearSecuritySocketLabel;
|
2009-03-03 09:44:41 +00:00
|
|
|
virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
|
|
|
|
virSecurityDomainGenLabel domainGenSecurityLabel;
|
2009-06-12 11:38:50 +00:00
|
|
|
virSecurityDomainReserveLabel domainReserveSecurityLabel;
|
2010-01-11 11:04:40 +00:00
|
|
|
virSecurityDomainReleaseLabel domainReleaseSecurityLabel;
|
|
|
|
virSecurityDomainGetProcessLabel domainGetSecurityProcessLabel;
|
|
|
|
virSecurityDomainSetProcessLabel domainSetSecurityProcessLabel;
|
|
|
|
virSecurityDomainSetAllLabel domainSetSecurityAllLabel;
|
|
|
|
virSecurityDomainRestoreAllLabel domainRestoreSecurityAllLabel;
|
2009-08-14 14:23:11 +01:00
|
|
|
virSecurityDomainRestoreHostdevLabel domainRestoreSecurityHostdevLabel;
|
|
|
|
virSecurityDomainSetHostdevLabel domainSetSecurityHostdevLabel;
|
2009-11-11 12:07:00 +00:00
|
|
|
virSecurityDomainSetSavedStateLabel domainSetSavedStateLabel;
|
|
|
|
virSecurityDomainRestoreSavedStateLabel domainRestoreSavedStateLabel;
|
2009-03-03 09:44:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is internally managed driver state and should only be accessed
|
|
|
|
* via helpers below.
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
char doi[VIR_SECURITY_DOI_BUFLEN];
|
|
|
|
} _private;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Global methods */
|
|
|
|
int virSecurityDriverStartup(virSecurityDriverPtr *drv,
|
|
|
|
const char *name);
|
|
|
|
|
2009-04-03 10:55:51 +00:00
|
|
|
int
|
2010-02-09 19:18:21 +00:00
|
|
|
virSecurityDriverVerify(virDomainDefPtr def);
|
2009-04-03 10:55:51 +00:00
|
|
|
|
2010-03-09 19:22:22 +01:00
|
|
|
# define virSecurityReportError(code, ...) \
|
2010-02-12 00:18:54 +01:00
|
|
|
virReportErrorHelper(NULL, VIR_FROM_SECURITY, code, __FILE__, \
|
2010-03-01 16:38:28 -07:00
|
|
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
2009-03-03 09:44:41 +00:00
|
|
|
|
|
|
|
/* Helpers */
|
|
|
|
void virSecurityDriverInit(virSecurityDriverPtr drv);
|
2010-02-09 19:18:21 +00:00
|
|
|
int virSecurityDriverSetDOI(virSecurityDriverPtr drv,
|
2009-03-03 09:44:41 +00:00
|
|
|
const char *doi);
|
|
|
|
const char *virSecurityDriverGetDOI(virSecurityDriverPtr drv);
|
|
|
|
const char *virSecurityDriverGetModel(virSecurityDriverPtr drv);
|
|
|
|
|
|
|
|
#endif /* __VIR_SECURITY_H__ */
|