Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect sudo -V output #386

Closed
blemouzy opened this issue Jun 27, 2024 · 7 comments
Closed

Incorrect sudo -V output #386

blemouzy opened this issue Jun 27, 2024 · 7 comments

Comments

@blemouzy
Copy link

Hello,

I working on an ARM based embedded system with Yocto.

I noticed a strange sudo -V output (floating values are not correctly displayed) since sudo update from 1.9.13p3 to 1.9.15p2.

# sudo -V | grep timeout
Authentication timestamp timeout: f minutes
Password prompt timeout: f minutes

I also tried the 1.9.15p5 version with same result.

@millert
Copy link
Collaborator

millert commented Jul 2, 2024

This happens when using sudo's snprintf() replacement since it does not support floating point. That should only be necessary on older systems without a C99-compatible snprintf() (or systems without asprintf()).

In your case, this is probably because sudo was built with a cross-compiler and that configure test was unable to run. These days, it is probably safe to assume that snprintf() is C99-compliant when cross-compiling. If you are building your own sudo, you can set ac_cv_have_working_snprintf=yes in the environment to avoid the issue.

@blemouzy
Copy link
Author

blemouzy commented Jul 3, 2024

This happens when using sudo's snprintf() replacement since it does not support floating point. That should only be necessary on older systems without a C99-compatible snprintf() (or systems without asprintf()).

What explains the regression between 1.9.13p3 and 1.9.15p2?

In your case, this is probably because sudo was built with a cross-compiler and that configure test was unable to run. These days, it is probably safe to assume that snprintf() is C99-compliant when cross-compiling. If you are building your own sudo, you can set ac_cv_have_working_snprintf=yes in the environment to avoid the issue.

I made the test:

  • add EXTRA_OECONF += "ac_cv_have_working_snprintf=yes" to the sudo_%.bbappend file
  • check config.log:
# Before
12157:ac_cv_have_working_snprintf=cross   

# After
12157:ac_cv_have_working_snprintf=yes
  • check sudo -V output:
Authentication timestamp timeout: f minutes
Password prompt timeout: f minutes

⮕ same result

@millert
Copy link
Collaborator

millert commented Jul 3, 2024

Sorry, you also need to set ac_cv_have_working_vsnprintf=yes.

In sudo 1.9.13 vfprintf() was used to display those strings so the problem did not occur. The switch to using vsnprintf() in 1.9.14 is what triggered the issue. Sudo 1.9.16 will avoid the problem by treating ac_cv_have_working_snprintf=cross and ac_cv_have_working_vsnprintf=cross the same as "yes".

@blemouzy
Copy link
Author

blemouzy commented Jul 4, 2024

Sorry, you also need to set ac_cv_have_working_vsnprintf=yes.

That effectively work now!

In sudo 1.9.13 vfprintf() was used to display those strings so the problem did not occur. The switch to using vsnprintf() in 1.9.14 is what triggered the issue.

Thanks for the explanation and thanks for support.

Sudo 1.9.16 will avoid the problem by treating ac_cv_have_working_snprintf=cross and ac_cv_have_working_vsnprintf=cross the same as "yes".

Nice!
Link to the associated commit: 920710b

@blemouzy blemouzy closed this as completed Jul 4, 2024
@egtvedt
Copy link

egtvedt commented Sep 2, 2024

After this change I'm not able to link sudo release 1.9.16, I did a comment on the configure script change in 920710b#r146098350

I'm no good with autoconf, so if somebody could point failure on my side or the change here needs further improvements?

Update: By adding ac_cv_have_working_snprintf=yes and ac_cv_have_working_vsnprintf=yes when configuring, sudo 1.9.16 compiles and link for me.

Update2: And I have the following in config.h

/* Enable replacement (v)snprintf if system (v)snprintf is broken. */
/* #undef PREFER_PORTABLE_SNPRINTF */

Which looks correct.

@millert
Copy link
Collaborator

millert commented Sep 3, 2024

@egtvedt Can you test whether 3e12cac this this for you?

@egtvedt
Copy link

egtvedt commented Sep 3, 2024

@egtvedt Can you test whether 3e12cac this this for you?

This commit solves my configure problem, and I get the expected defines in config.h

#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
/* #undef PREFER_PORTABLE_SNPRINTF */

Thank you for solving so quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants