cron - setusercontext failed for root

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

cron - setusercontext failed for root

Torsten-2
I'm setting up an embedded system from scratch with OpenBSD. The system
is VERY much stripped down to the absolute necessary files only.

I have troubles using cron:

in /etc/crontab I have:
-----------------------------------
SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HOME=/tmp/log
*/1 * * * * root /bin/sh -c "echo DEBUGMARKER>/tmp/console"
-----------------------------------

I have an entry for root in /etc/passwd (and master.passwd respectively).

Nevertheless, when cron starts, I get this:

-----------------------------------
# /usr/sbin/cron -n -x sch
debug flags enabled: sch
[9538] cron started
[9538] GMToff=7200
[9538] Target time=1209315180, sec-to-wait=28
[9538] tick(53,16,26,3,0)
user [root:0:0:...] cmd="/bin/sh -c "echo DEBUGMARKER>/tmp/console""
[9538] Target time=1209315240, sec-to-wait=60
log_it: (root 14005) CMD (/bin/sh -c "echo DEBUGMARKER>/tmp/console")
setusercontext failed for root
log_it: (root 20135) MAIL (mailed 31 bytes of output but got status 0x0001)
[9538] Target time=1209315240, sec-to-wait=59
-----------------------------------

The problem seems to be: "setusercontext failed for root"
Why is this so and what can I do to solve this?

A little more explanation:
I'm not using std init-procedure, the kernel loads a custom init-script
which does the things the system is designed to do. One task in the
init-script is to start crond which is just there to do some cleanups
regularly.

Help will be appreciated!

T.

Reply | Threaded
Open this post in threaded view
|

Re: cron - setusercontext failed for root

Stuart Henderson
On 2008-04-27, Torsten <[hidden email]> wrote:
> I'm setting up an embedded system from scratch with OpenBSD. The system
> is VERY much stripped down to the absolute necessary files only.

Then it's no longer OpenBSD which is the whole operating system,
the most you can say is it's using some parts from OpenBSD, so it's
not exactly on-topic here. You can do a lot more to track down the
problem yourself...

> The problem seems to be: "setusercontext failed for root"
> Why is this so

Some suggestions:

1. ktrace(1)/kdump(1)
2. gdb(1).
3. Compare one/both of the above with a working system.
4. Look at setusercontext(3), work out what might fail.

Reply | Threaded
Open this post in threaded view
|

Solved: cron - setusercontext failed for root

Torsten-2
>> The system
>> is VERY much stripped down to the absolute necessary files only.
> Then it's no longer OpenBSD

It can be discussed if an OS where I delete certain files cannot be
called by its original name anymore.

Anyway, I found that cron needs /etc/login.conf though that file is not
mentioned in any documentation.

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Otto Moerbeek
On Mon, Apr 28, 2008 at 01:26:47PM +0200, Torsten wrote:

>>> The system is VERY much stripped down to the absolute necessary files
>>> only.
>> Then it's no longer OpenBSD
>
> It can be discussed if an OS where I delete certain files cannot be called
> by its original name anymore.
>
> Anyway, I found that cron needs /etc/login.conf though that file is not
> mentioned in any documentation.

Are you serious? You break things by removing an essential, documented
file and then complain?

Please stop wasting our time.

        -Otto

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Peter Nicolai Mathias Hansteen
In reply to this post by Torsten-2
Torsten <[hidden email]> writes:

> Anyway, I found that cron needs /etc/login.conf though that file is
> not mentioned in any documentation.

That's odd.  On my machines 'man login.conf' gives me a rather
informative man page.  

On OpenBSD, to find something that is in fact not at all documented is
a very rare occurence indeed, and if I understand these things
correctly, would merit a bug report.

--
Peter N. M. Hansteen, member of the first RFC 1149 implementation team
http://bsdly.blogspot.com/ http://www.bsdly.net/ http://www.nuug.no/
"Remember to set the evil bit on all malicious network traffic"
delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Stuart Henderson
In reply to this post by Torsten-2
On 2008/04/28 13:26, Torsten wrote:
>>> The system is VERY much stripped down to the absolute necessary files
>>> only.
>> Then it's no longer OpenBSD
>
> It can be discussed if an OS where I delete certain files cannot be
> called by its original name anymore.

This has been done to death in the archives.

> Anyway, I found that cron needs /etc/login.conf though that file is not
> mentioned in any documentation.

"man setusercontext" gives you login_cap(3), references to
/etc/login.conf are scattered all over it.

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Torsten-2
In reply to this post by Otto Moerbeek
> Are you serious? You break things by removing an essential, documented
> file and then complain?

It's obvious that I must be dumb. I wasn't smart enough to find out that
running a program by schedule (which cron does) _must_ have something to
do with the _login_ process, which login.conf is obviously related to!!!
As if that wasn't obvious!!! ;-)

Stupid as I am I thought that documentation of cron would point to the
files that cron relies upon. Or at least, if it finds a file missing, it
would tell me which one it is. Stupid me! ;-)


 > Please stop wasting our time.

And after not finding a solution by reading documentation and trying all
sorts of debugging options, I was so stupid to ask this ML if someone
has an idea which files cron would need. I'm so sorry to have wasted
your precious time! Again: stupid me! I apologize.

Anyway, I'm glad Stuart Henson was kind enough to point an obvious idiot
like me also to setusercontext (3), which finally led me to find cron is
missing login.conf. @Stu: Thx alot!

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Otto Moerbeek
On Mon, Apr 28, 2008 at 03:17:34PM +0200, Torsten wrote:

>> Are you serious? You break things by removing an essential, documented
>> file and then complain?
>
> It's obvious that I must be dumb. I wasn't smart enough to find out that
> running a program by schedule (which cron does) _must_ have something to do
> with the _login_ process, which login.conf is obviously related to!!! As if
> that wasn't obvious!!! ;-)
>
> Stupid as I am I thought that documentation of cron would point to the
> files that cron relies upon. Or at least, if it finds a file missing, it
> would tell me which one it is. Stupid me! ;-)

Lemme tell you there are more files on which cron relies that are not
in the cron man pages. The function call that was in error
(setusercontext()) clearly cross references login.conf.

>
>
> > Please stop wasting our time.
>
> And after not finding a solution by reading documentation and trying all
> sorts of debugging options, I was so stupid to ask this ML if someone has
> an idea which files cron would need. I'm so sorry to have wasted your
> precious time! Again: stupid me! I apologize.
>
> Anyway, I'm glad Stuart Henson was kind enough to point an obvious idiot
> like me also to setusercontext (3), which finally led me to find cron is
> missing login.conf. @Stu: Thx alot!

If you start breaking stuff by removing files without the knowledge
how things work, you should expect harsh treatment from this list.
What's next, sombody complaining he cannot login because he removed
the passwd file?

        -Otto

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Torsten-2
> If you start breaking stuff by removing files without the knowledge
> how things work, you should expect harsh treatment from this list.
> What's next, sombody complaining he cannot login because he removed
> the passwd file?

Without any irony: I'm sorry if I didn't make things clear enough! The
problem here is that you understood I'd be complaining, which I really
wasn't! I was just asking! And I still think I asked questions that are
somewhat "valid", though I must admit, not in "normal" situations.

My project is an embedded system which has certain requirements that do
not meet in a "normal" setup. So, yes, there may come up very special
requirements where I could even imagine that /etc/passwd must be removed
(not that I'm about to do that). I don't see why it shouldn't be valid
to ask which files a certain program relies upon.

Anyway: I got you.

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Paul de Weerd
In reply to this post by Torsten-2
On Mon, Apr 28, 2008 at 03:17:34PM +0200, Torsten wrote:
>> Are you serious? You break things by removing an essential, documented
>> file and then complain?
>
> It's obvious that I must be dumb. I wasn't smart enough to find out that
> running a program by schedule (which cron does) _must_ have something to do
> with the _login_ process, which login.conf is obviously related to!!! As if
> that wasn't obvious!!! ;-)

Yes, it is *totally* obvious if you actually know what you're doing.

All users have a login class. This login class is configured in
/etc/master.passwd (which you knew about). Details about the login
classes are stored in login.conf or its related databases. This is
basic unix sysadmin stuff.

You don't have to know about it, but if you start deleting stuff where
you don't know what it does, you may end up shooting yourself in the
foot. Another unix thing, you can very easily shoot yourself in your
feet.

If you don't know what you're doing, don't do it. Before deleting a
file you don't know its use of, read up on its manpage - that's what
it's there for. It just may be very important.

> Stupid as I am I thought that documentation of cron would point to the
> files that cron relies upon. Or at least, if it finds a file missing, it
> would tell me which one it is. Stupid me! ;-)

Cron relies on users being properly configured. Users being properly
configured require passwd and login databases. Maybe you knew this :
cron also relies on the dynamic linker and its related files. You
didn't delete those, did you ? But the cron docs did not tell you
about /var/run/ld.so.hints and the config that sets it up, right ? You
managed to not delete the runtine link editor directory cache or the
stuff that sets it up (probably) because you knew how important it is.
What should we do with the next guy that deletes this stuff thinking
he doesn't need it and neglects to tell us when he comes here asking
for help ?

You didn't know the importance of login.conf and you burn your fingers
deleting it. Don't blame others for it, and don't play the "hey, I got
mistreated"-card either. It just makes you look lame.

You broke the thing, you got told off, you even got help. Learn and
move on, don't come crying about how stupid you are.

Cheers,

Paul 'WEiRD' de Weerd

--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Torsten-2
> Yes, it is *totally* obvious if you actually know what you're doing.

Well, I didn't say I know exactly what I'm doing. If everybody always
knew exactly what they're doing, this ML would be obsolete, wouldn't it?

Thanks a lot for your explanations (no irony! I've learned from it!)!!!
That helps me asking less stupid questions in the future.


> You don't have to know about it, but if you start deleting

Well I didn't tell yet, the idea is the other way round. I build up this
embedded system from scratch by putting the files that I need together,
not by deleting files from a full install. So I didn't delete anything,
I just didn't copy enough files together. That's not stupid at all, it's
a design-question. The design is as minimalistic as can be, it says that
the resulting system should not have _any_ obsolete files at all. So
that's why I set it up this way. I know it's not common and I know it's
not pure OpenBSD anymore, but there's nothing non-OpenBSD in it. And
yes: It's my lack of knowledge and I didn't mean to hide that at any time.


> If you don't know what you're doing, don't do it.

The world would be better if everybody would admit to this. But wouldn't
this be boring? ;-)


> cron also relies on the dynamic linker and its related files. You
> didn't delete those, did you ?

No, when I first tried to use a program that missed a lib, it told me so
and I could go and copy that file to my target system. It's easy when a
program tells you why it is in trouble.


> What should we do with the next guy that deletes this stuff thinking
> he doesn't need it and neglects to tell us when he comes here asking
> for help ?

Try to help him. What else? Why would you read this ML if not to help
others that don't get along with whatever they do with OpenBSD? You guys
helped me, too: Stuards hint indirectly pointed me to login.conf. If you
don't want to help, then just don't do it. So I don't see any problem here.


> You didn't know the importance of login.conf and you burn your fingers
> deleting it. Don't blame others for it,

I didn't intend to blame anybody. I'm pretty aware that what I do is not
"the usual way". But I still think it's a valid way to do things.


> and don't play the "hey, I got mistreated"-card either.

Nah, come on, how could I react to "don't waste my time!" if not by a
little irony? ;-) I'd be a lamer if I took everything too seriously!


> It just makes you look lame.

I'm sorry that's what you think about me. Anyway, in my age, it's not so
important anymore if a few people think you're lame. Maybe I am. Who cares?

But let's no abuse this ML for personal discussions. I think I got you
and I'm willing to do my best to provide the correct complete
information that are in relation to my problem, next time I bother you
here on this ML. OK?

Reply | Threaded
Open this post in threaded view
|

Re: Solved: cron - setusercontext failed for root

Ingo Schwarze
Torsten wrote on Mon, Apr 28, 2008 at 04:42:09PM +0200:

> If everybody always knew exactly what they're doing,
> this ML would be obsolete, wouldn't it?

No.  Knowledge does not obsolete communication.
Quite to the contrary, knowledge helps communication.

> Why would you read this ML if not to help others
> that don't get along with whatever they do with OpenBSD?

For example to find bug reports, fix the bugs and thus make OpenBSD
better.  At least that's what otto@ is doing a lot; he is one of the
quickest and most helpful developers in that respect.

At work (not related to OpenBSD), i am in the habit of looking into bug
reports if they smell related to the code i'm responsible for, just to
speed things up and spare our escalation engineers painful digging
through code i know more or less by heart anyway.  But it is embarrassing
if, after spending some time on a ticket, you find out that somebody
simply did something stupid but neglected to state what was done.

By the way, there's nothing wrong with experimentation -
you can learn a lot from it.  But when trying weird things,
try hard to solve your own problems and avoid asking for help.
Ignoring bogus reports and questions really isn't easy; usually,
you lose quite some time before you realize it's actually bogus.