* [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions
@ 2010-10-06 23:31 Joe Perches
2010-10-07 6:54 ` Wolfram Sang
2010-10-07 10:48 ` Rabin Vincent
0 siblings, 2 replies; 4+ messages in thread
From: Joe Perches @ 2010-10-06 23:31 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: Andrew Morton, LKML
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2039acd..6f8a1d4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1346,6 +1346,14 @@ sub process {
}
}
+ if ($rawline =~ /^ create mode (\d+) ([\w\.\/\-]+)$/) {
+ my $mode = $1;
+ my $file = $2;
+ if ($mode ne "100644" && !($file =~ /\.(sh|pl|py|awk)$/)) {
+ WARN("FILE '$file' should probably use file permission 100644 not $mode\n" . $herecurr);
+ }
+ }
+
# Check for wrappage within a valid hunk of the file
if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
ERROR("patch seems to be corrupt (line wrapped?)\n" .
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions
2010-10-06 23:31 [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions Joe Perches
@ 2010-10-07 6:54 ` Wolfram Sang
2010-10-11 14:39 ` Michal Marek
2010-10-07 10:48 ` Rabin Vincent
1 sibling, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2010-10-07 6:54 UTC (permalink / raw)
To: Joe Perches; +Cc: Andy Whitcroft, Andrew Morton, LKML
[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]
On Wed, Oct 06, 2010 at 04:31:31PM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> scripts/checkpatch.pl | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2039acd..6f8a1d4 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1346,6 +1346,14 @@ sub process {
> }
> }
>
> + if ($rawline =~ /^ create mode (\d+) ([\w\.\/\-]+)$/) {
Do you really need to escape ./- in the character-class? ISTR this is not
needed.
> + my $mode = $1;
> + my $file = $2;
> + if ($mode ne "100644" && !($file =~ /\.(sh|pl|py|awk)$/)) {
> + WARN("FILE '$file' should probably use file permission 100644 not $mode\n" . $herecurr);
> + }
What about checking for no filename extension, too, and changing the message to
something like "use proper file permission or proper extension"?
> + }
> +
> # Check for wrappage within a valid hunk of the file
> if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
> ERROR("patch seems to be corrupt (line wrapped?)\n" .
>
>
> --
> 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/
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions
2010-10-06 23:31 [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions Joe Perches
2010-10-07 6:54 ` Wolfram Sang
@ 2010-10-07 10:48 ` Rabin Vincent
1 sibling, 0 replies; 4+ messages in thread
From: Rabin Vincent @ 2010-10-07 10:48 UTC (permalink / raw)
To: Joe Perches; +Cc: Andy Whitcroft, Andrew Morton, LKML
On Thu, Oct 7, 2010 at 5:01 AM, Joe Perches <joe@perches.com> wrote:
> + if ($rawline =~ /^ create mode (\d+) ([\w\.\/\-]+)$/) {
> + my $mode = $1;
> + my $file = $2;
> + if ($mode ne "100644" && !($file =~ /\.(sh|pl|py|awk)$/)) {
> + WARN("FILE '$file' should probably use file permission 100644 not $mode\n" . $herecurr);
> + }
> + }
> +
There's a vaguely similar patch already in -mm. That one also handles mode
changes and doesn't require the presence of the diff summary. Have a look in
case you missed it, maybe it does most of what you want and you can base
something on that:
http://userweb.kernel.org/~akpm/mmotm/broken-out/checkpatch-check-for-incorrect-permissions.patch
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions
2010-10-07 6:54 ` Wolfram Sang
@ 2010-10-11 14:39 ` Michal Marek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Marek @ 2010-10-11 14:39 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Joe Perches, Andy Whitcroft, Andrew Morton, LKML
On 7.10.2010 08:54, Wolfram Sang wrote:
> On Wed, Oct 06, 2010 at 04:31:31PM -0700, Joe Perches wrote:
>> + my $mode = $1;
>> + my $file = $2;
>> + if ($mode ne "100644" && !($file =~ /\.(sh|pl|py|awk)$/)) {
>> + WARN("FILE '$file' should probably use file permission 100644 not $mode\n" . $herecurr);
>> + }
>
> What about checking for no filename extension, too, and changing the message to
> something like "use proper file permission or proper extension"?
That would result in too many false positives, I'm afraid. What about
checking for files with a shebang?
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-11 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-06 23:31 [PATCH] scripts/checkpatch.pl: Warn on non-executable files created with non 100644 file permissions Joe Perches
2010-10-07 6:54 ` Wolfram Sang
2010-10-11 14:39 ` Michal Marek
2010-10-07 10:48 ` Rabin Vincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox