*/
User::User()
-: Uid (-1)
-, Gid (-1)
+: Uid ((uid_t)-1)
+, Gid ((gid_t)-1)
{
} // User::User()
{
Name.clear();
Password.clear();
- // FIXME: Uid and Gid is unsigned
- Uid= -1;
- Gid= -1;
+ Uid= (uid_t)-1;
+ Gid= (gid_t)-1;
Gecos.clear();
Homedir.clear();
Shell.clear();
*/
bool User::is_valid() const
{
- // FIXME: Uid and Gid is unsigned, so the first expression is always true!
- return (Uid >= 0) and (Gid >= 0)
+ return (Uid != (uid_t)-1) and (Gid != (gid_t)-1)
and not Name.empty()
;
} // eo User::is_valid() const
Group::Group()
-: Gid (-1) // FIXME: Gid is unsigned
+: Gid ((gid_t)-1)
{
} // eo Group::Group()
{
Name.clear();
Password.clear();
- // FIXME: Gid is unsigned
- Gid= -1;
+ Gid= (gid_t)-1;
Members.clear();
} // eo Group::clear()
*/
bool Group::is_valid() const
{
- // FIXME: Gid is unsigned, so the first expression is always true!
- return (Gid >= 0) and not Name.empty();
+ return (Gid != (gid_t)-1) and not Name.empty();
} // eo Group::is_valid() const
/**
CPPUNIT_TEST(NormalizePath1);
CPPUNIT_TEST(NormalizePath2);
CPPUNIT_TEST(TestUserAndGroupStuff1);
+ CPPUNIT_TEST(TestUserAndGroupStuff2);
CPPUNIT_TEST(TestFileModes1);
CPPUNIT_TEST(TestPidOf1);
CPPUNIT_TEST(TestCopyFileSourceFail);
} // TestUserAndGroupStuff1()
+ void TestUserAndGroupStuff2()
+ {
+ // Test if is_valid() works correctly
+ User user_root;
+ CPPUNIT_ASSERT_EQUAL( false, user_root.is_valid() );
+ Group group_root;
+ CPPUNIT_ASSERT_EQUAL( false, group_root.is_valid() );
+ }
void TestFileModes1()
{