Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S271124AbTG1VNY (ORCPT ); Mon, 28 Jul 2003 17:13:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S271149AbTG1VNY (ORCPT ); Mon, 28 Jul 2003 17:13:24 -0400 Received: from fmr03.intel.com ([143.183.121.5]:46547 "EHLO hermes.sc.intel.com") by vger.kernel.org with ESMTP id S271124AbTG1VNM (ORCPT ); Mon, 28 Jul 2003 17:13:12 -0400 Message-ID: <3F259195.7070707@intel.com> Date: Mon, 28 Jul 2003 14:11:49 -0700 From: Arun Sharma User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 X-Accept-Language: en-us, en MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: binfmt handler searching issues Content-Type: multipart/mixed; boundary="------------060605010007070605050505" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4605 Lines: 78 This is a multi-part message in MIME format. --------------060605010007070605050505 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit A script such as #!/bin/foo.bar ... where /bin/foo.bar is handled by binfmt_misc, is not handled correctly i.e. the interpreter of foo.bar doesn't receive the correct arguments. The binfmt_misc handler requires that bprm->filename is appropriately filled so that the argv[1] could be correctly passed to the interpreter. However, binfmt_script, as it exists today doesn't populate bprm->filename correctly. Another motivation for this patch is the output of ps. Emulators which use binfmt_misc may want to keep the output of ps consistent with native execution. This requires preserving bprm->filename. The attached patch guarantees this even if we have to go through several binfmt handlers (think of finite loops involving binfmt_script and binfmt_misc). -Arun --------------060605010007070605050505 Content-Type: text/plain; name="binfmt_interp.patch" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="binfmt_interp.patch" LS0tIGxpbnV4L2ZzL2V4ZWMuYy0JVGh1IE1hciAxMyAxMTo0Mjo1MSAyMDAzCisrKyBsaW51 eC9mcy9leGVjLmMJVGh1IE1hciAxMyAxM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lLCAnLicpOworCWNoYXIgKnAgPSBz dHJyY2hyKGJwcm0tPmludGVycCwgJy4nKTsKIAlzdHJ1Y3QgbGlzdF9oZWFkICpsOwogCiAJ Zm9yIChsID0gZW50cmllcy5uZXh0OyBsICE9ICZlbnRyaWVzOyBsID0gbC0+bmV4dCkgewpA QCAtMTI1LDEzICsxMjUsMTMgQEAKIAlpZiAoIShmbXQtPmZsYWdzICYgTUlTQ19GTVRfUFJF U0VSVkVfQVJHVjApKSB7CiAJCXJlbW92ZV9hcmdfemVybyhicHJtKTsKIAl9Ci0JcmV0dmFs ID0gY29weV9zdHJpbmdzX2tlcm5lbCgxLCAmYnBybS0+ZmlsZW5hbWUsIGJwcm0pOworCXJl dHZhbCA9IGNvcHlfc3RyaW5nc19rZXJuZWwoMSwgJmJwcm0tPmludGVycCwgYnBybSk7CiAJ aWYgKHJldHZhbCA8IDApIGdvdG8gX3JldDsgCiAJYnBybS0+YXJnYysrOwogCXJldHZhbCA9 IGNvcHlfc3RyaW5nc19rZXJuZWwoMSwgJmluYW1lX2FkZHIsIGJwcm0pOwogCWlmIChyZXR2 YWwgPCAwKSBnb3RvIF9yZXQ7IAogCWJwcm0tPmFyZ2MrKzsKLQlicHJtLT5maWxlbmFtZSA9 IGluYW1lOwkvKiBmb3IgYmluZm10X3NjcmlwdCAqLworCWJwcm0tPmludGVycCA9IGluYW1l OwkvKiBmb3IgYmluZm10X3NjcmlwdCAqLwogCiAJZmlsZSA9IG9wZW5fZXhlYyhpbmFtZSk7 CiAJcmV0dmFsID0gUFRSX0VSUihmaWxlKTsK --------------060605010007070605050505-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/