From owner-freebsd-jail@FreeBSD.ORG Fri Oct 5 16:29:41 2012 Return-Path: Delivered-To: freebsd-jail@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE08C1065670 for ; Fri, 5 Oct 2012 16:29:41 +0000 (UTC) (envelope-from joris.dedieu@gmail.com) Received: from mail-qa0-f47.google.com (mail-qa0-f47.google.com [209.85.216.47]) by mx1.freebsd.org (Postfix) with ESMTP id 615498FC1F for ; Fri, 5 Oct 2012 16:29:40 +0000 (UTC) Received: by mail-qa0-f47.google.com with SMTP id i29so507565qaf.13 for ; Fri, 05 Oct 2012 09:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=McwHoYQhx9qYbp+wsVIml1lOMwD22Q1noPdynU3PUn8=; b=t8q1GEeoPFm+EGHbs0UoThjaEp18p13wEvxEH5lJ/Yqyz9OGIg0rGdgIcYx8cWrUCI s4k/EtkepGmQG8B0dY3lqhgKsXKkmPCEAWqH+/AY9GLuR2cSsTTR4o12a3jognSEbdEF kPybsFVex0FbctWTUXksf3DTm+wMTEd5B50BQAxvJsDbwN1k5RyP+Mm/54RHHmk0ZqBV +OgJ0vaiHlIrAPKPGSYLvxHFjSshwz0h85PG+7rO92JwZ+WZylpoEwAi3aMicjkXKWwL 9oVIwIHJl2DmR0P7KSATTqo2NY3YdUqacyau7wcGKrpJKul8CirA1+amG8b5BytF31xz yR3g== MIME-Version: 1.0 Received: by 10.224.200.134 with SMTP id ew6mr17397639qab.54.1349454579397; Fri, 05 Oct 2012 09:29:39 -0700 (PDT) Received: by 10.224.136.151 with HTTP; Fri, 5 Oct 2012 09:29:39 -0700 (PDT) In-Reply-To: References: Date: Fri, 5 Oct 2012 18:29:39 +0200 Message-ID: From: joris dedieu To: freebsd-jail@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: create an empty jail with libjail X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Oct 2012 16:29:41 -0000 2012/10/5 joris dedieu : > Hi, > I try to create an empty jail using libjail. Something equivalent to > "jail -c name=empty host.hostname=empty path=/var/empty persist". I've > tried with jailparam_import and jail_setv on 8.3 and 9.1 but both > failed. I can't find where my code is wrong. > > Eg 1: > > #include > #include > #include > > int > main(int argc, char **argv) > { > struct jailparam params[4]; > int jid; > jailparam_init(¶ms[0], "name"); > jailparam_import(¶ms[0], "empty"); > jailparam_init(¶ms[1], "host.hostname"); > jailparam_import(¶ms[1], "empty.rmdir.fr"); > jailparam_init(¶ms[2], "path"); > jailparam_import(¶ms[2], "/var/empty"); > /*jailparam_init(¶ms[3], "persist"); > jailparam_import(¶ms[3], NULL);*/ > > if((jid = jailparam_set(params, 4, JAIL_CREATE)) == -1) > err(1, "jailparam_set"); > printf("jid is %d", jid); > return 0; > } The problem with this code (except the comments) was in my world. It works fot me after reinstalling the libc. The second code (with jail_setv, still not working). I will try to find what's wrong with it. Joris > > > jailparam_import fails with EINVAL (from libc's jail_set but i don't > know why) > > > Eg 2: > > #include > #include > #include > > int > main(int argc, char **argv) > { > int jid; > if((jid = jail_setv(JAIL_CREATE, > "name", "empty" > "host.hostname", "empty", > "path", "/var/empty", > "persist", NULL, NULL > )) == -1) > err(1, "jail_setv"); > printf("jid is %d", jid); > return 0; > } > > jail_setv fails with ENOENT. I think it comes from libjail's > jailparam_type as persist is not in security.jail.param's mib in > prison 0 (see .lib/libjail/jail.c:854). > > > I really don't understand why it doesn't work. If someone could have a > little look, it would be grate. > > Regards > Joris