Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Virus exploring a security hole in the 'home' command.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 48 of 48 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jim Richardson  
View profile  
 More options Jan 25 2004, 10:00 pm
Newsgroups: comp.os.linux.misc
From: Jim Richardson <warl...@eskimo.com>
Date: Sun, 25 Jan 2004 12:58:34 -0800
Local: Sun, Jan 25 2004 9:58 pm
Subject: Re: Virus exploring a security hole in the 'home' command.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 25 Jan 2004 19:47:41 GMT,
 Juha Siltala <jsilt...@gmx.net> wrote:

eek! no, bad idea!

What if it does something you *don't* want root to do?

better to strace it and see, rather than run it as root.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAFC36d90bcYOAWPYRAnlfAJwPT49f74p4/JXXrAQGO5EidYvMAQCeM+68
p3JIKffuY0WawlyKnqwAy2k=
=16b1
-----END PGP SIGNATURE-----

--
Jim Richardson     http://www.eskimo.com/~warlock
Windows: Microsoft's tax on computer illiterates.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Murphy  
View profile  
 More options Jan 25 2004, 11:03 pm
Newsgroups: comp.os.linux.misc
From: Ed Murphy <emurph...@socal.rr.com>
Date: Sun, 25 Jan 2004 22:03:51 GMT
Local: Sun, Jan 25 2004 11:03 pm
Subject: Re: Virus exploring a security hole in the 'home' command.

"Am I putting him on or is he putting me on?"
     -Lloyd Fellowes (Michael Caine) in _Noises Off_

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Mike releases the "home" command under the GPL" by José de Paula
José de Paula  
View profile  
 More options Jan 25 2004, 11:23 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: José de Paula <jose_de_pa...@ig.com.br>
Date: Sun, 25 Jan 2004 20:23:51 -0200
Local: Sun, Jan 25 2004 11:23 pm
Subject: Re: Mike releases the "home" command under the GPL
Em Sun, 25 Jan 2004 17:42:55 +0000, Albert van der Horst escreveu:

> I miss the configure script, the Makefile and man file.
> An rpm would be nice too.
> Also this program doesn't follow the gnu presciptions of
> the --version and --help options.

I bet you didn't see GNU hello...
http://www.gnu.org/software/hello/

Download it, compile it and run it... You will laugh at the source.

--
Quidquid latine dictum sit altum viditur


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Virus exploring a security hole in the 'home' command." by Juha Siltala
Juha Siltala  
View profile  
 More options Jan 25 2004, 11:27 pm
Newsgroups: comp.os.linux.misc
From: Juha Siltala <jsilt...@gmx.net>
Date: Sun, 25 Jan 2004 22:27:35 GMT
Local: Sun, Jan 25 2004 11:27 pm
Subject: Re: Virus exploring a security hole in the 'home' command.

In article <q8nde1-uh2....@grendel.myth>, Jim Richardson wrote:

> On Sun, 25 Jan 2004 19:47:41 GMT,
>  Juha Siltala <jsilt...@gmx.net> wrote:
>> When something doesn't work as you expected, always try as root! It might
>> be a permission problem :)

> eek! no, bad idea!

> What if it does something you *don't* want root to do?

Uhhh... I'm pretty sure you don't want it to do 'rm -rf $HOME', which is
what we were talking about. This thread has long been for jesters only :)

--
Juha Siltala
http://www.edu.helsinki.fi/activity/people/jsiltala/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Nigel releases shorter 'home' command under gpl" by Wolfgang Denk
Wolfgang Denk  
View profile  
 More options Jan 26 2004, 2:12 am
Newsgroups: comp.os.linux.misc
From: Wolfgang Denk <w...@denx.muc.de>
Date: Mon, 26 Jan 2004 00:17:36 GMT
Local: Mon, Jan 26 2004 1:17 am
Subject: Re: Nigel releases shorter 'home' command under gpl

Nigel Feltham <nigel.felt...@btinternet.com> writes:
>Here are my shorter GPL versions of your home command.
>Version 1 :-
>alias home=cd
>Version 2 :-
>alias home='cd $HOME'

Arghh... there are two major shortcomings of your proposals:

* They are not object-oriented
* They are not compatible with the original solution
  (different behaviour: not bug-compatible).

Wolfgang Denk

--
See us @ Embedded World, Nuremberg, Feb 17 - 19,  Hall 12.0 Booth 440
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88   Web: www.denx.de
Any technology distinguishable from magic is insufficiently advanced.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Mike releases the "home" command under the GPL" by Kelsey Bjarnason
Kelsey Bjarnason  
View profile  
 More options Jan 26 2004, 2:20 am
Newsgroups: comp.os.linux.misc
From: Kelsey Bjarnason <kels...@lightspeed.bc.ca>
Date: Sun, 25 Jan 2004 17:20:24 -0800
Local: Mon, Jan 26 2004 2:20 am
Subject: Re: Mike releases the "home" command under the GPL
[snips]

On Sun, 25 Jan 2004 17:03:15 -0500, Madhusudan Singh wrote:
>> #include <iostream>

>> int main()
>> {
>> char* name= new char[strlen(getlogin()) + 1];

From the man page:
RETURN VALUE
       getlogin returns a pointer to the user name when successful,  and  NULL
       on failure.

If getlogin returns NULL, the code above is borked; it'll call strlen on
a NULL pointer - crash time.

>> strcpy(name,getlogin());

Assuming new[] actually worked - i.e. you have memory assigned to name -
this is okay.  However, if new[] fails, then one of two things is going to
happen; either it's going to toss an excption at new[] (and there's no
handler, hence the app bombs) or, worse, it doesn't toss an exception, but
simply returns NULL - and the strcpy fails, making the app puke.

>> if(strcmp(name, "root") == 0)
>> {
>> std::cout<<"going to home directory...\n";
>> FILE* pipe;
>> pipe =        popen("cd /root/", "w"); pclose(pipe);

Assumes popen succeeeds and actually does the equivalent of a cd.  Neither
seems to be the case.

>> } else{
>> char* base = "/home/";
>> strcat(base, name);

strcat to a string literal?  Undefined behaviour and an almost certain app
crash.

>> FILE* bong;
>> std::cout<<"going to home directory...\n"; bong = popen(base,"w");
>> pclose(bong);
>> }
>> }
>> delete [] name;
>> return 0;
>> }

All in all, not even a particularly good attempt.  Undefined behaviour,
app crashes right, left and center, and even if everything does "work" as
one might hope, no assurance it actually does what it claims to in the
first place.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew Pitcher  
View profile  
 More options Jan 26 2004, 7:42 am
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Lew Pitcher <lpitc...@sympatico.ca>
Date: Sun, 25 Jan 2004 12:19:13 -0500
Local: Sun, Jan 25 2004 6:19 pm
Subject: Re: Mike releases the "home" command under the GPL
Mike Cox wrote:
> /*
>    ********   home command ********
>    The 'home'command takes you to your home directory if
>    you've been wandering far, and don't want to type so
>    much.  Just type "home" at the shell, and you're immediatly
>    transported to /home/yourusername/

[snip]

Well, with that, you've simultaneously proved that
a) you don't understand the concept of Unix processes,
b) you don't understand the use of the popen() function,
c) you don't understand the idea of usability, and
d) you don't know how to locate a user's HOME directory.

Perhaps you should try again, after getting a bit more familiar with the
environment in which you are working.

--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johan Lindquist  
View profile  
 More options Jan 26 2004, 10:09 am
Newsgroups: comp.os.linux.misc
From: Johan Lindquist <s...@smilfinken.net>
Date: Mon, 26 Jan 2004 10:01:56 +0100
Local: Mon, Jan 26 2004 10:01 am
Subject: Re: Mike releases the "home" command under the GPL
So anyway, it was like, 21:01 CET Jan 25 2004, you know? Oh, and, yeah,
Tony Lawrence was all like, "Dude,

>>On Sun, 25 Jan 2004 02:15:06 GMT, Frostbite <bill.ga...@ms.com> wrote:
>>>Mike Cox wrote:
>>>> ******** home command ********

[..]

> It would be even more amusing to submit it to the Patent Office.

> They'd probably approve it, and then IBM would contest it and show
> that they already patented it years ago..

Since it's freely downloadable (being posted to a public news group
and all), SCO would claim the rights and sue everyone who uses it and
any technology remotely resembling it. Probably including the single
'cd' command as well, based on the claim that the 'cd' source has
(unspecified) lines from the 'home' source code in it. After all,
it aim to do the same thing as 'home' but doesn't work quite as
well.

--
Time flies like an arrow, fruit flies like a banana.      Perth ---> *
 09:59:00 up 1 day, 17:34,  1 user,  load average: 2.04, 2.32, 2.25
$ cat /dev/bollocks                      Registered Linux user #261729
envisioneer strategic ROI


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Grant Edwards  
View profile  
 More options Jan 26 2004, 4:03 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Grant Edwards <gra...@visi.com>
Date: 26 Jan 2004 15:03:21 GMT
Local: Mon, Jan 26 2004 4:03 pm
Subject: Re: Mike releases the "home" command under the GPL
On 2004-01-25, Lew Pitcher <lpitc...@sympatico.ca> wrote:

> Mike Cox wrote:
>> /*
>>        ********   home command ********
>>        The 'home'command takes you to your home directory if
>>        you've been wandering far, and don't want to type so
>>        much.  Just type "home" at the shell, and you're immediatly
>>        transported to /home/yourusername/
> [snip]

> Well, with that, you've simultaneously proved that
> a) you don't understand the concept of Unix processes,
> b) you don't understand the use of the popen() function,
> c) you don't understand the idea of usability, and
> d) you don't know how to locate a user's HOME directory.

You forgot:

e) he can troll Usenet.

[At least I _hope_ it was a troll.]

--
Grant Edwards                   grante             Yow!  ONE LIFE TO LIVE for
                                  at               ALL MY CHILDREN in ANOTHER
                               visi.com            WORLD all THE DAYS OF
                                                   OUR LIVES.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew Pitcher  
View profile  
 More options Jan 26 2004, 4:30 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Lew.Pitc...@td.com (Lew Pitcher)
Date: Mon, 26 Jan 2004 15:17:09 GMT
Local: Mon, Jan 26 2004 4:17 pm
Subject: Re: Mike releases the "home" command under the GPL
On 26 Jan 2004 15:03:21 GMT, Grant Edwards <gra...@visi.com> wrote:

He may be a troll, but I've seen enough newbie attempts like his to give him the
benefit of the doubt.

In any case, even if he /is/ a troll, the newbies don't always know that, and
his code is now "on the net" (available to Google, for instance) as an answer to
the newbie's question of how to change the shell's cwd programmatically. Our
negative responses should help newbies to determine that the OPs code is
useless.

--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Murphy  
View profile  
 More options Jan 26 2004, 5:53 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Ed Murphy <emurph...@socal.rr.com>
Date: Mon, 26 Jan 2004 16:53:33 GMT
Local: Mon, Jan 26 2004 5:53 pm
Subject: Re: Mike releases the "home" command under the GPL

On Mon, 26 Jan 2004 15:17:09 +0000, Lew Pitcher wrote:
> In any case, even if he /is/ a troll, the newbies don't always know that, and
> his code is now "on the net" (available to Google, for instance) as an answer to
> the newbie's question of how to change the shell's cwd programmatically. Our
> negative responses should help newbies to determine that the OPs code is
> useless.

ObPuzzle:  Create the shortest program that (effectively) does 'su'
followed by 'rm -rf /', without it being blindingly obvious from a
first read-through of the source code that that's what it does.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The Onion Man  
View profile  
 More options Jan 26 2004, 6:05 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: The Onion Man <IanPe...@netscamybrainspe.net>
Date: Mon, 26 Jan 2004 17:07:13 +0000
Local: Mon, Jan 26 2004 6:07 pm
Subject: Re: Mike releases the "home" command under the GPL
Jim Richardson sighed and said:

> cd, with no options, will return you to $HOME, your home directory.

Dammit!

I've been busy typing cd ~

That's /TWO/ unnecessary characters. No wonder my productivity is so low.

--
Ian

Actually I think I prefer tomatoes now.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chrisv  
View profile  
 More options Jan 26 2004, 6:24 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: chrisv <chr...@nospam.invalid>
Date: Mon, 26 Jan 2004 11:23:08 -0600
Local: Mon, Jan 26 2004 6:23 pm
Subject: Re: Mike releases the "home" command under the GPL

On Mon, 26 Jan 2004 15:17:09 +0000, Lew Pitcher wrote:
>>e) he can troll Usenet.

>>[At least I _hope_ it was a troll.]

> He may be a troll, but I've seen enough newbie attempts like his to give
> him the benefit of the doubt.

Mike Cocks is a Wintroll.  He's a sick f*ck who gets his jollies proving
what a stupid a$$hole he is by saying stuff like "when MS makes free
software like IE, it gets huge market share, while Linux is free and gets
small market share, so that's proof that Linux must suck" - like IE being
bundled with the monopoly OS isn't the real issue.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Smith  
View profile  
 More options Jan 26 2004, 7:50 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Tim Smith <reply_in_gr...@mouse-potato.com>
Date: Mon, 26 Jan 2004 18:50:02 GMT
Local: Mon, Jan 26 2004 7:50 pm
Subject: Re: Mike releases the "home" command under the GPL
In article <pan.2004.01.26.17.07.13.3...@netscamybrainspe.net>, The Onion

Man wrote:
> Jim Richardson sighed and said:
>> cd, with no options, will return you to $HOME, your home directory.

> Dammit!

> I've been busy typing cd ~

> That's /TWO/ unnecessary characters. No wonder my productivity is so low.

Wow!  I wish I'd known about that.  I've been doing this when I need to get
to my home directory:

    1. type "cd "

    2. open another xterm

    3. run "pwd" in the other xterm

    4. copy/paste the pwd output to the first xterm

    5. hit return on the first xterm

    6. close the second xterm

And that is simplified...I won't even mention the 5 feet of snow and typing
uphill both ways...

--
--Tim Smith


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew Pitcher  
View profile  
 More options Jan 26 2004, 8:21 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Lew.Pitc...@td.com (Lew Pitcher)
Date: Mon, 26 Jan 2004 19:08:27 GMT
Local: Mon, Jan 26 2004 8:08 pm
Subject: Re: Mike releases the "home" command under the GPL
On Mon, 26 Jan 2004 18:50:02 GMT, Tim Smith <reply_in_gr...@mouse-potato.com>
wrote:

My favourite:

  cd `cat /etc/passwd | grep \`whoami\` | gawk -F: ' { print $6 }'`

--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew Pitcher  
View profile  
 More options Jan 26 2004, 8:26 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Lew.Pitc...@td.com (Lew Pitcher)
Date: Mon, 26 Jan 2004 19:13:18 GMT
Local: Mon, Jan 26 2004 8:13 pm
Subject: Re: Mike releases the "home" command under the GPL

On Mon, 26 Jan 2004 19:08:27 GMT, Lew.Pitc...@td.com (Lew Pitcher) wrote:
>My favourite:

>  cd `cat /etc/passwd | grep \`whoami\` | gawk -F: ' { print $6 }'`

And, yes, I know it has a UUOC - that's the whole idea, mate.

--
Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johan Lindquist  
View profile  
 More options Jan 26 2004, 10:19 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
Followup-To: comp.os.linux.advocacy
From: Johan Lindquist <s...@smilfinken.net>
Date: Mon, 26 Jan 2004 22:14:41 +0100
Local: Mon, Jan 26 2004 10:14 pm
Subject: Re: Mike releases the "home" command under the GPL
["Followup-To:" header set to comp.os.linux.advocacy.]
So anyway, it was like, 20:13 CET Jan 26 2004, you know? Oh, and, yeah,
Lew Pitcher was all like, "Dude,

> On Mon, 26 Jan 2004 19:08:27 GMT, Lew.Pitc...@td.com (Lew Pitcher) wrote:
>>My favourite:

>>  cd `cat /etc/passwd | grep \`whoami\` | gawk -F: ' { print $6 }'`

> And, yes, I know it has a UUOC - that's the whole idea, mate.

Well hell, why stop there. 'whoami' is abit of a cheat.

cd `cat /etc/passwd | grep \`who | grep \
   \\\`env | grep TTY | sed -e 's/.*\(pts.*\)/\1/'\\\` \
   | cut -d' ' -f1\` | gawk -F: '{print $6}'`

I /think/ it may work for both telnet and ssh logins. Adding support
for virtual consoles is left as an excercise for the next supplicant.

--
Time flies like an arrow, fruit flies like a banana.      Perth ---> *
 21:58:38 up 2 days,  5:34,  2 users,  load average: 2.07, 2.09, 2.08
$ cat /dev/bollocks                      Registered Linux user #261729
strategize wireless metrics


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alan Connor  
View profile  
 More options Jan 26 2004, 10:41 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Alan Connor <zzz...@xxx.yyy>
Date: Mon, 26 Jan 2004 21:41:13 GMT
Local: Mon, Jan 26 2004 10:41 pm
Subject: Re: Mike releases the "home" command under the GPL

On Mon, 26 Jan 2004 19:08:27 GMT, Lew Pitcher <Lew.Pitc...@td.com> wrote:

<snip>

> My favourite:

>   cd `cat /etc/passwd | grep \`whoami\` | gawk -F: ' { print $6 }'`

<laughs out loud>

:-)

AC


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Baxter  
View profile  
 More options Jan 27 2004, 1:24 am
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Andy Baxter <ne...@earthsong.null.free-online.co.uk>
Date: Tue, 27 Jan 2004 00:31:25 +0000
Local: Tues, Jan 27 2004 1:31 am
Subject: Re: Mike releases the "home" command under the GPL
At earth time Mon, 26 Jan 2004 15:17:09 +0000, the following transmission
was received from the entity known as Lew Pitcher:

he was posting trollfully on comp.os.linux.advocacy a while back, but this
looks to me more like he's decided linux is worth giving a try, but he's
too eager to prove he can do something, and didn't have the patience to
get it right. <rueful grin about echoes of my own psychology>

p.s. to mike cox - if you want to show people code like this, you could
try comp.os.linux.development.apps, and make it clear you're using it as
an example to learn linux coding.

--
http://www.niftybits.ukfsn.org/

remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The Ghost In The Machine  
View profile  
 More options Jan 27 2004, 2:01 am
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: The Ghost In The Machine <ew...@sirius.athghost7038suus.net>
Date: Tue, 27 Jan 2004 01:01:03 GMT
Local: Tues, Jan 27 2004 2:01 am
Subject: Re: Mike releases the "home" command under the GPL
In comp.os.linux.advocacy, Mike Cox
<mikecoxli...@yahoo.com>
 wrote
on 24 Jan 2004 17:49:42 -0800
<3d6111f1.0401241749.22dc5...@posting.google.com>:

> /*
>    ********   home command ********
>    The 'home'command takes you to your home directory if
>    you've been wandering far, and don't want to type so
>    much.  Just type "home" at the shell, and you're immediatly
>    transported to /home/yourusername/

Pedant points.

[1] This won't work unless one subinvokes a shell.
[2] The home directory can be anywhere on the disk; it need
    not sit in /home.  (The location is of course specified
    in /etc/passwd.)

>    (c) 2004 Mike Cox. Released under the GNU GPL License.
>         email:  mikecoxli...@yahoo.com
>    web: www.geocities.com/mikecoxlinux/

[3] You are in technical violation of the License, as you
    did not provide it with the software submission. :-)
    Fortunately, that's easily fixed; the text version is
    readily available.  (The HTML version has some issues,
    mostly because of images.)

>    compile instructions:
>    g++ -o home home.cpp

>    install instructions:
>    move it to the /bin directory.

[4] Operation not recommended as the c++ library is typically in
    /usr/lib.  However, I'd have to look.

>    ..Or create a Makefile as follows:
>    home: home.cpp
>            g++ -o home home.cpp
>    install:
>            mv home /bin/
>    clean:
>            rm home

[5] There are better ways of structuring a Makefile, though the above will
    work.  For example,

        all: home
        %: %.o
            $(LINK.cc) -o $@ $^

    might work for a lot of applications.

> */
> #include <iostream>

#include <stdio.h>
     // for FILE *, popen(), pclose(), perror()
#include <unistd.h>
     // for getlogin()
#include <string.h>
     // for strcmp()

> int main()
> {

// optimization
      int l = strlen(getlogin());

>    char* name= new char[strlen(getlogin()) + 1];

// optimization
      char * name = new char[l+1];

// strdup() could be used here instead

>    strcpy(name,getlogin());
>    if(strcmp(name, "root") == 0)

[6] Special case is not required.

>    {
>            std::cout<<"going to home directory...\n";

[7] std::endl.

>            FILE* pipe;
>            pipe =  popen("cd /root/", "w");    

              if(pipe == null) { perror("popen"); exit(-1); }

>            pclose(pipe);
>    } else{
>            char* base = "/home/";

[8] Either use ~, ~user or getpwnam().  (See [2])

>            strcat(base, name);
>            FILE* bong;
>            std::cout<<"going to home directory...\n";
>            bong = popen(base,"w");

              if(bong == null) { perror("popen"); exit(-1); }

>            pclose(bong);
>    }

>    delete [] name;

// free() should be used here if strdup() replaces new char[] above

>    return 0;
> }

I will give you credit for the following:

[A] Dynamic string allocation for getlogin().
[B] Correct usage of delete[].
[C] Correctly returning 0 from main().
[D] Using <iostream> instead of the deprecated <iostream.h>
[E] Using the GPL.

Not bad for a first attempt, even if the idea is totally botched
from the word 'go' because one cannot set the current directory
of a parent process.

--
#191, ewi...@earthlink.net
It's still legal to go .sigless.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roger Leigh  
View profile  
 More options Jan 27 2004, 5:07 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Roger Leigh <${rog...@invalid.whinlatter.uklinux.net.invalid>
Date: Tue, 27 Jan 2004 15:50:08 +0000
Local: Tues, Jan 27 2004 4:50 pm
Subject: Re: Mike releases the "home" command under the GPL

I've got a much better version here ;-)

/*
 * hm.c
 * Securely enter home directory....
 * Copyright (C) 2004  Roger Leigh
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 *************************************************************************** **/

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>

int
main (int argc, char *argv[])
{
  const char *dir;
  uid_t uid;
  gid_t gid;
  struct passwd *pass;
  const char *shell;

  /* Get user ID */
  uid = getuid ();
  if ((pass = getpwuid (uid)) == NULL)
    {
      fprintf (stderr, "Could not get username for user %lu\n", (unsigned long) uid);
      exit (EXIT_FAILURE);
    }

  /* Validate input */
  if (argc > 2)
    {
      fprintf (stderr, "Usage: %s dir\n", argv[0]);
      exit (EXIT_FAILURE);
    }
  else if (argc == 2)
    dir = argv[1];
  else
    dir = getenv("HOME");
  if (dir == NULL)
    dir = pass->pw_dir;
  if (!strcmp(dir, ""))
    dir = "/";

  /* Enter the directory */
  if (chdir (dir))
    {
      fprintf (stderr, "Could not chdir to %s: %s\n", dir,
               strerror (errno));
      exit (EXIT_FAILURE);
    }
  /* printf ("Entered dir: %s\n", dir); */

  /* Set up environment */
  setenv("HOME", pass->pw_dir, 1);

  /* Run shell */
  if (pass->pw_shell)
    shell = pass->pw_shell;
  else
    shell = "/bin/false";
  if (execl (shell, shell, (const char *) NULL))
    {
      fprintf (stderr, "Could not exec %s: %s\n", shell, strerror (errno));
      exit (EXIT_FAILURE);
    }
  /* This should never be reached */
  exit(EXIT_FAILURE);

}

--
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The Ghost In The Machine  
View profile  
 More options Jan 28 2004, 10:00 pm
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: The Ghost In The Machine <ew...@sirius.athghost7038suus.net>
Date: Wed, 28 Jan 2004 21:00:37 GMT
Local: Wed, Jan 28 2004 10:00 pm
Subject: Re: Mike releases the "home" command under the GPL
In comp.os.linux.advocacy, Roger Leigh
<${rog...@invalid.whinlatter.uklinux.net.invalid>
 wrote
on Tue, 27 Jan 2004 15:50:08 +0000
<87ptd5l7bj....@wrynose.whinlatter.uklinux.net>:

True enough.

Interesting, and should work reasonably well -- although the
environment is a little on the munged side as the user's
home directory is being accessed using your account.

Of course 'su' already solves that particular subproblem,
if anyone really cares. :-)  Perhaps we should call this
"hmshell"? :-)

--
#191, ewi...@earthlink.net
It's still legal to go .sigless.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roger Leigh  
View profile  
 More options Jan 30 2004, 10:18 am
Newsgroups: comp.os.linux.misc, comp.os.linux.advocacy
From: Roger Leigh <${rog...@invalid.whinlatter.uklinux.net.invalid>
Date: Thu, 29 Jan 2004 18:30:49 +0000
Local: Thurs, Jan 29 2004 7:30 pm
Subject: Re: Mike releases the "home" command under the GPL
The Ghost In The Machine <ew...@sirius.athghost7038suus.net> writes:

> In comp.os.linux.advocacy, Roger Leigh
> <${rog...@invalid.whinlatter.uklinux.net.invalid>
>  wrote
>> /*
>>  * hm.c
>>  * Securely enter home directory....
>>  * Copyright (C) 2004  Roger Leigh
[...]
>>   /* Set up environment */
>>   setenv("HOME", pass->pw_dir, 1);

>>   /* Run shell */
> Interesting, and should work reasonably well -- although the
> environment is a little on the munged side as the user's
> home directory is being accessed using your account.

Yes, it should read

   setenv("HOME", dir, 1);

> Of course 'su' already solves that particular subproblem,
> if anyone really cares. :-)  Perhaps we should call this
> "hmshell"? :-)

:-)

This was originally a setuid program to execute a shell in a
restricted chroot environment.  I just stripped the extra
functionality, and tweaked it a little (which is where the HOME buglet
comes from, since it used to exec a login shell with really fascist
security checking).

--
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 100,000 Newsgroups - 19 Different Servers! =-----


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google