X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fguestfs-internal.h;h=99a04045705b7144baadcb2fec111720d21fb6a8;hp=46576bb2d4c1923c3e2d53a802d709b4f248ce0c;hb=c79ba93f7e53f6a62b5793ba35f1c3b13527eef6;hpb=13d8963d8c0203e1f72c519e5acf79ebf7cccb4c diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 46576bb..99a0404 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -60,6 +60,38 @@ #define xdr_uint32_t xdr_u_int32_t #endif +/* Some limits on what the inspection code will read, for safety. */ + +/* Small text configuration files. + * + * The upper limit is for general files that we grep or download. The + * largest such file is probably "txtsetup.sif" from Windows CDs + * (~500K). This number has to be larger than any legitimate file and + * smaller than the protocol message size. + * + * The lower limit is for files parsed by Augeas on the daemon side, + * where Augeas is running in reduced memory and can potentially + * create a lot of metadata so we really need to be careful about + * those. + */ +#define MAX_SMALL_FILE_SIZE (2 * 1000 * 1000) +#define MAX_AUGEAS_FILE_SIZE (100 * 1000) + +/* Maximum Windows Registry hive that we will download to /tmp. Some + * registries can be legitimately very large. + */ +#define MAX_REGISTRY_SIZE (100 * 1000 * 1000) + +/* Maximum RPM or dpkg database we will download to /tmp. RPM + * 'Packages' database can get very large: 70 MB is roughly the + * standard size for a new Fedora install, and after lots of package + * installation/removal I have seen well over 100 MB databases. + */ +#define MAX_PKG_DB_SIZE (300 * 1000 * 1000) + +/* Maximum size of Windows explorer.exe. 2.6MB on Windows 7. */ +#define MAX_WINDOWS_EXPLORER_SIZE (4 * 1000 * 1000) + /* Network configuration of the appliance. Note these addresses are * only meaningful within the context of the running appliance. QEMU * translates network connections to these magic addresses into @@ -118,7 +150,7 @@ struct guestfs_h char *qemu_help, *qemu_version; /* Output of qemu -help, qemu -version. */ char **cmdline; /* Qemu command line. */ - int cmdline_size; + size_t cmdline_size; int verbose; int trace; @@ -138,6 +170,8 @@ struct guestfs_h int selinux; /* selinux enabled? */ + int pgroup; /* Create process group for children? */ + char *last_error; int last_errnum; /* errno, or 0 if there was no errno */ @@ -166,6 +200,11 @@ struct guestfs_h FILE *trace_fp; char *trace_buf; size_t trace_len; + + /* User cancelled transfer. Not signal-atomic, but it doesn't + * matter for this case because we only care if it is != 0. + */ + int user_cancel; }; /* Per-filesystem data stored for inspect_os. */ @@ -212,6 +251,8 @@ enum inspect_os_distro { OS_DISTRO_LINUX_MINT, OS_DISTRO_MANDRIVA, OS_DISTRO_SLACKWARE, + OS_DISTRO_CENTOS, + OS_DISTRO_SCIENTIFIC_LINUX, }; enum inspect_os_package_format { @@ -315,11 +356,28 @@ extern int guestfs___match3 (guestfs_h *g, const char *str, const pcre *re, char #endif extern int guestfs___feature_available (guestfs_h *g, const char *feature); extern void guestfs___free_string_list (char **); -extern int guestfs___checkpoint_cmdline (guestfs_h *g); -extern void guestfs___rollback_cmdline (guestfs_h *g, int pos); +extern size_t guestfs___checkpoint_cmdline (guestfs_h *g); +extern void guestfs___rollback_cmdline (guestfs_h *g, size_t pos); extern void guestfs___call_callbacks_void (guestfs_h *g, uint64_t event); extern void guestfs___call_callbacks_message (guestfs_h *g, uint64_t event, const char *buf, size_t buf_len); extern void guestfs___call_callbacks_array (guestfs_h *g, uint64_t event, const uint64_t *array, size_t array_len); +#if defined(HAVE_PCRE) && defined(HAVE_HIVEX) +extern int guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, int is_block, int is_partnum); +extern char *guestfs___download_to_tmp (guestfs_h *g, struct inspect_fs *fs, const char *filename, const char *basename, int64_t max_size); +extern char *guestfs___case_sensitive_path_silently (guestfs_h *g, const char *); +extern struct inspect_fs *guestfs___search_for_root (guestfs_h *g, const char *root); +extern int guestfs___parse_unsigned_int (guestfs_h *g, const char *str); +extern int guestfs___parse_unsigned_int_ignore_trailing (guestfs_h *g, const char *str); +extern int guestfs___parse_major_minor (guestfs_h *g, struct inspect_fs *fs); +extern char *guestfs___first_line_of_file (guestfs_h *g, const char *filename); +extern int guestfs___first_egrep_of_file (guestfs_h *g, const char *filename, const char *eregex, int iflag, char **ret); +typedef int (*guestfs___db_dump_callback) (guestfs_h *g, const unsigned char *key, size_t keylen, const unsigned char *value, size_t valuelen, void *opaque); +extern int guestfs___read_db_dump (guestfs_h *g, const char *dumpfile, void *opaque, guestfs___db_dump_callback callback); +extern int guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs); +extern int guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs); +extern int guestfs___check_freebsd_root (guestfs_h *g, struct inspect_fs *fs); +extern int guestfs___check_windows_root (guestfs_h *g, struct inspect_fs *fs); +#endif #define error(g,...) guestfs_error_errno((g),0,__VA_ARGS__) #define perrorf guestfs_perrorf