[PATCH] state: check return value of chown

Daniel Golle daniel at makrotopia.org
Mon Jan 4 12:26:30 EST 2021


On Mon, Jan 04, 2021 at 05:08:22PM -0000, Karl Palsson wrote:
> 
> Daniel Golle <daniel at makrotopia.org> wrote:
> > On Sat, Jan 02, 2021 at 10:01:36PM +0800, yeholmes at outlook.com
> > wrote:
> 
> > > -			chown(p->pw_dir, p->pw_uid, p->pw_gid);
> > > +			if (chown(p->pw_dir, p->pw_uid, p->pw_gid))
> > > +				fprintf(stderr, "Failed to change ownership for %s\n", p->pw_dir);
> > 
> > Please let's not have a custom error message for cases which
> > practically never occur. If we would really cover all that,
> > around 80% of the size of executables like procd would be error
> > messages. Imho an assertion is the right thing to do here.
> > 
> 
> Do we compile with assertions enabled?

Interesting point actually: I just checked, assertions are compiled
into code unless NDEBUG is defined which we don't. Could be an idea for
tiny targets to do so...

> 
> Sincerely,
> Karl Palsson






More information about the openwrt-devel mailing list