# Anyone knows this warning?

**URL:** <https://www.ruby-forum.com/t/anyone-knows-this-warning/156989>\
**Category:** Ruby\
**Created:** [January 6, 2009, 9:08am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989 "2009-01-06T09:08:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 9:08am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/1 "2009-01-06T09:08:26Z")

</div>

When my ruby runs an external program, it will get this warning:  
warning: Insecure world writable dir SOMEDIR

I have checked the SOMEDIR and its permission mode is 777. Does anyone  
know this warning? How can I avoid this?

thanks

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 10:02am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/2 "2009-01-06T10:02:31Z")

</div>

Zhao Yi wrote:

> When my ruby runs an external program, it will get this warning:  
> warning: Insecure world writable dir SOMEDIR
> 
> I have checked the SOMEDIR and its permission mode is 777.

Which means it’s world-writable, as the warning says. In octal:

```
7 7 7

```

111 111 111  
rwx rwx rwx (user, group, world)

The warning comes from path\_check\_0 in file.c, which in turn is called  
from rb\_path\_check, which checks each of the directories in your PATH.

It’s basically saying: when you do system(“foo”), one of your PATH  
directories is world writable, so any random user on your system could  
have installed their own “foo” executable which does whatever they like  
(e.g. changing your password, or mailing your pr0n collection to your  
girlfriend 🙂

> How can I avoid this?

man chmod

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 10:27am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/3 "2009-01-06T10:27:47Z")

</div>

Zhao Yi wrote:

> why does ruby check its permission?

Because not heeding this warning is approximately the same as posting  
your password in clear text to all users on the system.

Even if you have no other users on your system, if someone happens to  
break in (e.g. through your web server or mail server), and gets a shell  
running as any daemon user, they can exploit this hole to run any script  
as _your_ userid.

> I do want this path writable. how  
> can I disable this warning?

I already pointed you at file.c. You will find a #if check in there,  
which lets you recompile ruby with this check disabled.

I’m not going to hint further. If you are smart enough to understand  
fully the consequences of disabling this check, then you a smart enough  
to read the configure script and recompile ruby with this check  
disabled.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 6, 2009, 10:10am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/4 "2009-01-06T10:10:59Z")

</div>

Brian C. wrote:

> Which means it’s world-writable, as the warning says. In octal:
> 
> ```
> 7 7 7
> 
> ```
> 
> 111 111 111  
> rwx rwx rwx (user, group, world)
> 
> man chmod

why does ruby check its permission? I do want this path writable. how  
can I disable this warning?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 7, 2009, 5:11am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/5 "2009-01-07T05:11:24Z")

</div>

On Tue 6.Jan’09 at 18:14:05 +0900, Zhao Yi wrote:

> why does ruby check its permission?  
> Why not? Ruby is letting you know that something bad can happen.

> I do want this path writable. how can I disable this warning?

ruby -W0 /path/to/your\_script

-drd

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 7, 2009, 6:47am UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/6 "2009-01-07T06:47:17Z")

</div>

Zhao Yi wrote:

> When my ruby runs an external program, it will get this warning:  
> warning: Insecure world writable dir SOMEDIR
> 
> I have checked the SOMEDIR and its permission mode is 777. Does anyone  
> know this warning? How can I avoid this?
> 
> thanks

World read, write and execute is a bad thing if you’re on a shared  
server with other users. Any good system will error and prevent it  
from running, instead of blindling running it. Else you risk issues  
where another user on the system can write to your files/directories,  
destroy, modify or delete your valuable data, as well as open  
exploitable potentials. If this is your own server and you don’t share  
it with any other users (or other users you can’t trust), then you can  
remove that check if you wish. Still, even when running with a lower  
privileged user instead of your own for better protection (if you run  
insecure scripts or you aren’t able to ensure they are secure), it  
still shouldn’t need world write/execute.

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [January 7, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/anyone-knows-this-warning/156989/7 "2009-01-07T14:57:37Z")

</div>

Zhao Yi wrote:

> When my ruby runs an external program, it will get this warning:  
> warning: Insecure world writable dir SOMEDIR
> 
> I have checked the SOMEDIR and its permission mode is 777. Does anyone  
> know this warning? How can I avoid this?
> 
> thanks

I understand that you want this directory to be world-writable, so this  
is probably not much use for your current situation, but handy to know  
nonetheless. You may want to configure a group, see /etc/groups, man  
groups, or man chgrp instead of having it be world-writable.

With that aside, there are two ways to modify the permissions for files  
and directories. In essence, it’s by name or by number. Using the names  
is better when beginning. See man chmod for more details.

Basically, you can use the syntax ‘chmod \<which\_access\_level\>\<+ or  
-\>\<which\_access\_type\>’.

\<which\_access\_level\> would be one of the following {a,u,g,o} where a is  
all (user group and other), u is user, g is group, and o is other  
(typically everyone else).

\<+ or -\> is a boolean true or false for turning on or off the  
permission.

\<which\_access\_type\> would be {r,w,x} where r is read, w is write, and x  
is execute.

So for example, if you wanted to remove the read ability for everyone  
except the user and group, you would use:

chmod o-r test-file.txt

You can group them as well, so the following is valid for adding write  
ability for the user and group:

chmod ug+r test-file.txt

The a for access level is a shortcut for all three. So to remove all  
types ability to execute a file:

chmod a-x test-file.txt

Also, you will probably want to check into man chown for how to change  
the user attribute for a specific file or set.

Hope that helps.

Best regards,  
Ryan Masters  
End Point Corp.  
removed\_email\_address@domain.invalid
