svn commit: r339918 - stable/12/sys/geom/eli
Xin LI
delphij at FreeBSD.org
Tue Oct 30 15:11:35 UTC 2018
Author: delphij
Date: Tue Oct 30 15:11:34 2018
New Revision: 339918
URL: https://svnweb.freebsd.org/changeset/base/339918
Log:
Restore backward compatibility for "attach" verb.
In r332361 and r333439, two new parameters were added to geli attach
verb using gctl_get_paraml, which requires the value to be present.
This would prevent old geli(8) binary from attaching geli(4) device
as they have no knowledge about the new parameters.
Restore backward compatibility by treating the absense of these two
values as seeing the default value supplied by userland.
PR: 232595
Reviewed by: oshogbo
Approved by: re (rgrimes)
Modified:
stable/12/sys/geom/eli/g_eli_ctl.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/geom/eli/g_eli_ctl.c
==============================================================================
--- stable/12/sys/geom/eli/g_eli_ctl.c Tue Oct 30 14:54:15 2018 (r339917)
+++ stable/12/sys/geom/eli/g_eli_ctl.c Tue Oct 30 15:11:34 2018 (r339918)
@@ -59,8 +59,8 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class
struct g_provider *pp;
const char *name;
u_char *key, mkey[G_ELI_DATAIVKEYLEN];
- int *nargs, *detach, *readonly, *dryrun;
- int keysize, error, nkey;
+ int *nargs, *detach, *readonly, *dryrunp;
+ int keysize, error, nkey, dryrun, dummy;
intmax_t *valp;
g_topology_assert();
@@ -81,12 +81,14 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class
return;
}
- valp = gctl_get_paraml(req, "keyno", sizeof(*valp));
- if (valp == NULL) {
- gctl_error(req, "No '%s' argument.", "keyno");
- return;
+ /* "keyno" is optional for backward compatibility */
+ nkey = -1;
+ valp = gctl_get_param(req, "keyno", &dummy);
+ if (valp != NULL) {
+ valp = gctl_get_paraml(req, "keyno", sizeof(*valp));
+ if (valp != NULL)
+ nkey = *valp;
}
- nkey = *valp;
if (nkey < -1 || nkey >= G_ELI_MAXMKEYS) {
gctl_error(req, "Invalid '%s' argument.", "keyno");
return;
@@ -98,10 +100,13 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class
return;
}
- dryrun = gctl_get_paraml(req, "dryrun", sizeof(*dryrun));
- if (dryrun == NULL) {
- gctl_error(req, "No '%s' argument.", "dryrun");
- return;
+ /* "dryrun" is optional for backward compatibility */
+ dryrun = 0;
+ dryrunp = gctl_get_param(req, "dryrun", &dummy);
+ if (dryrunp != NULL) {
+ dryrunp = gctl_get_paraml(req, "dryrun", sizeof(*dryrunp));
+ if (dryrunp != NULL)
+ dryrun = *dryrunp;
}
if (*detach && *readonly) {
@@ -161,7 +166,7 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class
md.md_flags |= G_ELI_FLAG_WO_DETACH;
if (*readonly)
md.md_flags |= G_ELI_FLAG_RO;
- if (!*dryrun)
+ if (!dryrun)
g_eli_create(req, mp, pp, &md, mkey, nkey);
explicit_bzero(mkey, sizeof(mkey));
explicit_bzero(&md, sizeof(md));
More information about the svn-src-stable-12
mailing list