Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755407AbYAHKpu (ORCPT ); Tue, 8 Jan 2008 05:45:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753222AbYAHKon (ORCPT ); Tue, 8 Jan 2008 05:44:43 -0500 Received: from ms0.nttdata.co.jp ([163.135.193.231]:42773 "EHLO ms0.nttdata.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbYAHKok (ORCPT ); Tue, 8 Jan 2008 05:44:40 -0500 Message-Id: <20080108095002.805987283@nttdata.co.jp> References: <20080108094903.484613061@nttdata.co.jp> User-Agent: quilt/0.46-1 Date: Tue, 08 Jan 2008 18:49:16 +0900 From: Kentaro Takeda To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Kentaro Takeda , Tetsuo Handa Subject: [TOMOYO #6 13/21] environment variable name check functions. X-OriginalArrivalTime: 08 Jan 2008 09:50:03.0053 (UTC) FILETIME=[D7382DD0:01C851DB] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="boundary-1" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10497 Lines: 143 --boundary-1 Content-Disposition: inline; filename="tomoyo-environ.patch" Content-Type: application/octect-stream Content-Transfer-Encoding: base64 VE9NT1lPIExpbnV4IGNoZWNrcyBlbnZpcm9ubWVudCB2YXJpYWJsZSdzIG5hbWVzIHBhc3NlZCB0 byBleGVjdmUoKQ0KYmVjYXVzZSBzb21lIGVudm9yaW5tZW50IHZhcmlhYmxlcyBhZmZlY3RzIHRv IHRoZSBiZWhhdmlvciBvZiBwcm9ncmFtDQpsaWtlIGFyZ3ZbMF0uDQoNCkVhY2ggcGVybWlzc2lv biBjYW4gYmUgYXV0b21hdGljYWxseSBhY2N1bXVsYXRlZCBpbnRvDQp0aGUgcG9saWN5IG9mIGVh Y2ggZG9tYWluIHVzaW5nICdsZW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lbnYsIGRvbWFpbiwgTlVMTCwgMCk7DQorDQorCQlp ZiAoIWlzX2VuZm9yY2UpDQorCQkJZXJyb3IgPSAwOw0KKwl9DQorDQorCXJldHVybiBlcnJvcjsN Cit9DQorDQorLyoqDQorICogdG15X2FkZF9lbnZfcG9saWN5IC0gYWRkIG9yIGRlbGV0ZSBlbnZp cm9ubWVudCB2YXJpYWJsZSBwb2xpY3kuDQorICogQGRhdGE6ICAgICAgYSBsaW5lIHRvIHBhcnNl Lg0KKyAqIEBkb21haW46ICAgIHBvaW50ZXIgdG8gInN0cnVjdCBkb21haW5faW5mbyIuDQorICog QGNvbmQ6ICAgICAgcG9pbnRlciB0byAic3RydWN0IGNvbmRpdGlvbl9saXN0Ii4gTWF5IGJlIE5V TEwuDQorICogQGlzX2RlbGV0ZTogaXMgdGhpcyBkZWxldGUgcmVxdWVzdD8NCisgKg0KKyAqIFJl dHVybnMgemVybyBvbiBzdWNjZXNzLg0KKyAqIFJldHVybnMgbm9uemVybyBvbiBmYWlsdXJlLg0K KyAqLw0KK2ludCB0bXlfYWRkX2Vudl9wb2xpY3koY2hhciAqZGF0YSwNCisJCQkgc3RydWN0IGRv bWFpbl9pbmZvICpkb21haW4sDQorCQkJIGNvbnN0IHN0cnVjdCBjb25kaXRpb25fbGlzdCAqY29u ZCwNCisJCQkgY29uc3QgYm9vbCBpc19kZWxldGUpDQorew0KKwlyZXR1cm4gdG15X2FkZF9lbnZf ZW50cnkoZGF0YSwgZG9tYWluLCBjb25kLA0KKwkJCQkgaXNfZGVsZXRlKTsNCit9DQoNCi0tIA0K --boundary-1-- -- 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/