Ticket #1655 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

System.Posix.User.getGroupEntryForName incorrect error for non-existent group

Reported by: Eelis Owned by: igloo
Priority: normal Milestone: 6.8.2
Component: libraries/unix Version: 6.6.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: getGroupEntryForName Blocked By:
Blocking: Related Tickets:

Description

The following program:

  import System.Posix.User
  main :: IO ()
  main = getGroupEntryForName "monkeys" >> return ()

gives the following output (on a system without a "monkeys" group):

  *** Exception: getGroupEntryForName: failed (Success)

The "(Success)" part is obviously wrong.

The problem is that the getGroupEntryForName implementation throws errno if getgrnam_r wrote NULL to the pointer pointed to by its last parameter, while the  getgrnam_r specification makes no guarantees about errno being set in that case.

Change History

Changed 6 years ago by igloo

  • owner set to igloo
  • milestone set to 6.8.2

The problem is when an error doesn't occur, but the name requested can't be found. The throwErrorIfNonZero_ doesn't happen, because 0 is returned, but the throwErrnoIfNull throws errno. We should throw something else in this situation.

Changed 6 years ago by igloo

  • status changed from new to closed
  • testcase set to getGroupEntryForName
  • resolution set to fixed

Fixed and merged:

Sat Nov 10 15:58:05 PST 2007  Ian Lynagh <igloo@earth.li>
  * Throw a proper exception if getGroupEntryForName fails to find an entry
  We used to get
   *** Exception: getGroupEntryForName: failed (Success)
  Fixes trac #1655

Changed 4 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.