Displaying 20 results from an estimated 171 matches for "int_of_string".
2017 Sep 19
1
Re: [PATCH v12 08/11] daemon: Implement inspection types and utility functions.
...on_from_major_minor str data =
> + if verbose () then
> + eprintf "parse_version_from_major_minor: parsing '%s'\n%!" str;
> +
> + if PCRE.matches re_major_minor str ||
> + PCRE.matches re_major_no_minor str then (
> + let major =
> + try Some (int_of_string (PCRE.sub 1))
> + with Not_found | Invalid_argument _ | Failure _ -> None in
> + let minor =
> + try Some (int_of_string (PCRE.sub 2))
> + with Not_found | Invalid_argument _ | Failure _ -> None in
> + match major, minor with
> + | None, None
> +...
2016 Dec 08
3
[PATCH 1/2] Remove most instances of OCaml warning 52.
...| 2 +-
6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/builder/index_parser.ml b/builder/index_parser.ml
index e5e4c6c..a3cae7d 100644
--- a/builder/index_parser.ml
+++ b/builder/index_parser.ml
@@ -113,7 +113,7 @@ let get_index ~downloader ~sigchecker
try Rev_int (int_of_string (List.assoc ("revision", None) fields))
with
| Not_found -> Rev_int 1
- | Failure "int_of_string" ->
+ | Failure _ ->
eprintf (f_"%s: cannot parse 'revision' field for '%s'\n") prog...
2019 Jan 29
2
[PATCH] v2v: linux: use NEVR for querying RPM packages (RHBZ#1669395)
...or =
+ let ver = List.find_map (
+ function
+ | { G.app2_name = name; G.app2_version = version }
+ when name = "rpm" -> Some version
+ | _ -> None
+ ) inspect.i_apps in
+ match String.nsplit "." ver with
+ | [major] -> int_of_string major, 0
+ | major :: minor :: _ -> int_of_string major, int_of_string minor
+ | _ -> error (f_"unrecognized RPM version: %s") ver in
+ let is_rpm_lt_4_11 =
+ rpm_major < 4 || (rpm_major = 4 && rpm_minor < 11) in
let pkg_name =
- sprintf &qu...
2019 Jan 14
1
[PATCH] inspect: fix inspection of partition-less devices (RHBZ#1661038)
...s_unix_fstab.ml
index 9f9478144..02956ae94 100644
--- a/daemon/inspect_fs_unix_fstab.ml
+++ b/daemon/inspect_fs_unix_fstab.ml
@@ -350,7 +350,7 @@ and resolve_fstab_device spec md_map os_type =
debug_matching "xdev";
let typ = PCRE.sub 1
and disk = PCRE.sub 2
- and part = int_of_string (PCRE.sub 3) in
+ and part = PCRE.sub 3 in
resolve_xdev typ disk part default
)
@@ -467,7 +467,7 @@ and resolve_fstab_device spec md_map os_type =
debug_matching "Hurd";
let typ = PCRE.sub 1
and disk = int_of_string (PCRE.sub 2)
- and part = int_of_string (P...
2019 Jan 30
0
Re: [PATCH] v2v: linux: use NEVR for querying RPM packages (RHBZ#1669395)
...> None
> + ) inspect.i_apps in
This has the nasty side effect of Not_found exception escaping if for
some reason we can't find the rpm version. I think you should catch
that case and assume old RPM.
> + match String.nsplit "." ver with
> + | [major] -> int_of_string major, 0
> + | major :: minor :: _ -> int_of_string major, int_of_string minor
> + | _ -> error (f_"unrecognized RPM version: %s") ver in
Because this comes from the guest the version field could contain any
old stuff, making this a bit error prone. I think it woul...
2023 Jun 29
1
[PATCH guestfs-tools] customize: Implement --chown option
...ize/customize_run.ml
index f03774e003..409b46edc6 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -153,6 +153,17 @@ let run (g : G.guestfs) root (ops : ops) =
let mode = if String.is_prefix mode "0" then "0o" ^ mode else mode in
g#chmod (int_of_string mode) path
+ | `Chown (uid_gid, path) ->
+ let uid, gid = String.split "." uid_gid in
+ let uid, gid =
+ try int_of_string uid, int_of_string gid
+ with Failure _ ->
+ error (f_"--chown: could not parse numeric UID.GID from \
+...
2016 Feb 18
0
[PATCH 3/3] Add and use an helper error function
...[x] ->
- eprintf "supermin: unable to parse rpm version string: %s\n" x;
- exit 1
+ | [] -> error "unable to parse empty rpm version string"
+ | [x] -> error "unable to parse rpm version string: %s" x
| major :: minor :: _ ->
try int_of_string major, int_of_string minor
with Failure "int_of_string" ->
- eprintf "supermin: unable to parse rpm version string: non-numeric, %s\n" version;
- exit 1 in
+ error "unable to parse rpm version string: non-numeric, %s" version in
rpm_ma...
2023 Jun 29
1
[PATCH guestfs-tools] customize: Implement --chown option
...x f03774e003..409b46edc6 100644
> --- a/customize/customize_run.ml
> +++ b/customize/customize_run.ml
> @@ -153,6 +153,17 @@ let run (g : G.guestfs) root (ops : ops) =
> let mode = if String.is_prefix mode "0" then "0o" ^ mode else mode in
> g#chmod (int_of_string mode) path
>
> + | `Chown (uid_gid, path) ->
> + let uid, gid = String.split "." uid_gid in
> + let uid, gid =
> + try int_of_string uid, int_of_string gid
> + with Failure _ ->
> + error (f_"--chown: could not...
2016 Feb 18
4
[PATCH 0/3] supermin: miscellaneous cleanups
Hi,
few cleanups in the supermin codebase; no actual functional change.
Thanks,
--
Pino Toscano (3):
ext2: simplify tracking of visited modules
utils: remove unused run_python function
Add and use an helper error function
src/build.ml | 20 +++++-----------
src/dpkg.ml | 4 +---
src/ext2_initrd.ml | 10 ++++----
src/kernel.ml | 27
2013 Apr 11
1
[PATCH] remove leading tabs in zypp driver
...l b/src/supermin_zypp_rpm.ml
index 1c6243d..4247d09 100644
--- a/src/supermin_zypp_rpm.ml
+++ b/src/supermin_zypp_rpm.ml
@@ -173,7 +173,7 @@ let rec zypp_rpm_list_files pkg =
| [filename; flags; mode; size] ->
let test_flag = String.contains flags in
let mode = int_of_string mode in
- let size = int_of_string size in
+ let size = int_of_string size in
if test_flag 'd' then None (* ignore documentation *)
else (
(* Skip unreadable files when called as non-root *)
@@ -206,7 +206,7 @@ let rec zypp_rpm_list_f...
2019 Jan 30
1
[PATCH v3] v2v: linux: use NEVR for querying RPM packages (RHBZ#1669395)
...let ver = List.find_map (
+ function
+ | { G.app2_name = name; G.app2_version = version }
+ when name = "rpm" -> Some version
+ | _ -> None
+ ) inspect.i_apps in
+ if PCRE.matches re_version ver then
+ (int_of_string (PCRE.sub 1), int_of_string (PCRE.sub 2))
+ else
+ (0, 0)
+ with Not_found ->
+ (* 'rpm' not installed? Hmm... *)
+ (0, 0) in
+ ver < (4, 11)
+ in
let pkg_name =
- sprintf "%s-%s-%s" app.G.app2_name
- app....
2019 Jan 30
1
[PATCH v2] v2v: linux: use NEVR for querying RPM packages (RHBZ#1669395)
...) =
+ let ver = List.find_map (
+ function
+ | { G.app2_name = name; G.app2_version = version }
+ when name = "rpm" -> Some version
+ | _ -> None
+ ) inspect.i_apps in
+ let ver =
+ if PCRE.matches re_version ver then
+ (int_of_string (PCRE.sub 1), int_of_string (PCRE.sub 2))
else
- sprintf "%ld:%s" app.G.app2_epoch pkg_name
- ) else
- pkg_name in
+ (0, 0) in
+ ver < (4, 11)
+ in
+ let pkg_name =
+ if app.G.app2_epoch = Int32.zero || is_rpm_lt_4_11 () then
+...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...g_as_root = Unix.geteuid () = 0 in
> - if running_as_root && backend_is_libvirt () then (
> - try
> - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
> - let uid =
> - if String.is_prefix user "+" then
> - int_of_string (String.sub user 1 (String.length user - 1))
> - else
> - (Unix.getpwnam user).pw_uid in
> - debug "setting owner of %s to %d:root" file uid;
> - Unix.chown file uid 0
> - with
> - | exn -> (* Print exception, but continue. *)
> -...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...z_1045069 file =
let running_as_root = Unix.geteuid () = 0 in
- if running_as_root && backend_is_libvirt () then (
- try
- let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
- let uid =
- if String.is_prefix user "+" then
- int_of_string (String.sub user 1 (String.length user - 1))
- else
- (Unix.getpwnam user).pw_uid in
- debug "setting owner of %s to %d:root" file uid;
- Unix.chown file uid 0
- with
- | exn -> (* Print exception, but continue. *)
- debug "could not set owner...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...() = 0 in
>> - if running_as_root && backend_is_libvirt () then (
>> - try
>> - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
>> - let uid =
>> - if String.is_prefix user "+" then
>> - int_of_string (String.sub user 1 (String.length user - 1))
>> - else
>> - (Unix.getpwnam user).pw_uid in
>> - debug "setting owner of %s to %d:root" file uid;
>> - Unix.chown file uid 0
>> - with
>> - | exn -> (* Print exception, bu...
2018 Aug 09
2
[PATCH] v2v: parse_libvirt_xml: handle srN CDROM devices (RHBZ#1612785)
...se
loop rest
in
- loop ["hd"; "sd"; "vd"; "xvd"; "fd"] in
+ if String.is_prefix dev "sr" then (
+ let name = String.sub dev 2 (String.length dev - 2) in
+ try Some (int_of_string name)
+ with Failure _ ->
+ warning (f_"could not parse device name ā%sā from the source libvirt XML") dev;
+ None
+ )
+ else
+ loop ["hd"; "sd"; "vd"; "xvd"; "fd"]...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...running_as_root && backend_is_libvirt () then (
> >> - try
> >> - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
> >> - let uid =
> >> - if String.is_prefix user "+" then
> >> - int_of_string (String.sub user 1 (String.length user - 1))
> >> - else
> >> - (Unix.getpwnam user).pw_uid in
> >> - debug "setting owner of %s to %d:root" file uid;
> >> - Unix.chown file uid 0
> >> - with
> >> - | ex...
2023 Jun 29
1
[v2v PATCH v2 2/3] lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
...t && backend_is_libvirt () then (
>>>> - try
>>>> - let user = Option.value ~default:"qemu" (libvirt_qemu_user ()) in
>>>> - let uid =
>>>> - if String.is_prefix user "+" then
>>>> - int_of_string (String.sub user 1 (String.length user - 1))
>>>> - else
>>>> - (Unix.getpwnam user).pw_uid in
>>>> - debug "setting owner of %s to %d:root" file uid;
>>>> - Unix.chown file uid 0
>>>> - with
>>...
2015 Aug 12
0
[PATCH 1/2] builder: add non-int revisions
...5d0e9..2c78fd9 100644
--- a/builder/index_parser.ml
+++ b/builder/index_parser.ml
@@ -112,9 +112,9 @@ let get_index ~downloader ~sigchecker
try Some (List.assoc ("checksum", None) fields)
with Not_found -> None in
let revision =
- try int_of_string (List.assoc ("revision", None) fields)
+ try Rev_int (int_of_string (List.assoc ("revision", None) fields))
with
- | Not_found -> 1
+ | Not_found -> Rev_int 1
| Failure "int_of_string" ->...
2016 May 19
0
[PATCH 2/2] customize: fix ownership when creating ~/.ssh/authorized_keys (RHBZ#1337561)
.../customize/ssh_key.ml b/customize/ssh_key.ml
index 7c482e7..d05816c 100644
--- a/customize/ssh_key.ml
+++ b/customize/ssh_key.ml
@@ -115,20 +115,24 @@ let do_ssh_inject_unix (g : Guestfs.guestfs) user selector =
user
in
let home_dir = read_user_detail "home" in
+ let uid = int_of_string (read_user_detail "uid") in
+ let gid = int_of_string (read_user_detail "gid") in
g#aug_close ();
(* Create ~user/.ssh if it doesn't exist. *)
let ssh_dir = sprintf "%s/.ssh" home_dir in
if not (g#exists ssh_dir) then (
g#mkdir ssh_dir;
- g#c...