Getgroupowner and GetOwner fixes

This commit is contained in:
Ugo Cirmignani
2018-06-02 23:13:48 +02:00
parent 19c4afc1f1
commit cb61af9a82
6 changed files with 11 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View File

@ -276,6 +276,7 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
continue;
}
//printf("\nFILE SIZE : %lld", data.fileSize);
data.owner = FILE_GetOwner(fileList[i]);

View File

@ -471,19 +471,20 @@ char * FILE_GetListPermissionsString(char *file) {
char * FILE_GetOwner(char *fileName)
{
int returnCode = 0;
char *toReturn;
struct stat info;
if (stat(fileName, &info) == -1 )
if ((returnCode = stat(fileName, &info)) == -1)
return NULL;
struct passwd *pw = getpwuid(info.st_uid);
if (pw->pw_name == 0)
struct passwd *pw;
if ( (pw = getpwuid(info.st_uid)) == NULL)
return NULL;
toReturn = (char *) malloc (strlen(pw->pw_name) + 1);
strcpy(toReturn, pw->pw_name);
return toReturn;
}
@ -493,9 +494,9 @@ char * FILE_GetGroupOwner(char *fileName)
struct stat info;
if (stat(fileName, &info) == -1 )
return NULL;
struct group *gr = getgrgid(info.st_gid);
struct group *gr;
if (gr->gr_name == 0)
if ((gr = getgrgid(info.st_gid)) == NULL)
return NULL;
toReturn = (char *) malloc (strlen(gr->gr_name) + 1);

View File

@ -6,8 +6,6 @@
</data>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/ugo/NetBeansProjects/uFTP/uftpd.cfg</file>
</group>
<group/>
</open-files>
</project-private>