mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtfile/dtcopy/sharedFuncs: CID 88204,88291,88852,88861,88876
This commit is contained in:
parent
51b7590c63
commit
19d824c2cc
1 changed files with 58 additions and 39 deletions
|
@ -197,7 +197,8 @@ get_path(char *path)
|
||||||
{
|
{
|
||||||
char *rpath, tmppath[MAX_PATH];
|
char *rpath, tmppath[MAX_PATH];
|
||||||
char * _DtCopyPathFromInput();
|
char * _DtCopyPathFromInput();
|
||||||
getcwd(tmppath,MAX_PATH);
|
if (!getcwd(tmppath,MAX_PATH))
|
||||||
|
return NULL;
|
||||||
rpath = _DtCopyPathFromInput(path,tmppath);
|
rpath = _DtCopyPathFromInput(path,tmppath);
|
||||||
return rpath;
|
return rpath;
|
||||||
}
|
}
|
||||||
|
@ -426,7 +427,10 @@ CopyCheckDeletePermissionRecur(
|
||||||
{
|
{
|
||||||
/* check for write permission in this directory */
|
/* check for write permission in this directory */
|
||||||
if (access(destinationPath, 04|02|01) < 0)
|
if (access(destinationPath, 04|02|01) < 0)
|
||||||
return -1;
|
{
|
||||||
|
closedir(dirp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* append a '/' to the end of directory name */
|
/* append a '/' to the end of directory name */
|
||||||
fnamep = destinationPath + strlen(destinationPath);
|
fnamep = destinationPath + strlen(destinationPath);
|
||||||
|
@ -440,10 +444,14 @@ CopyCheckDeletePermissionRecur(
|
||||||
|
|
||||||
/* recursively check permission on this file */
|
/* recursively check permission on this file */
|
||||||
if (CopyCheckDeletePermissionRecur(destinationPath))
|
if (CopyCheckDeletePermissionRecur(destinationPath))
|
||||||
return -1;
|
{
|
||||||
|
closedir(dirp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closedir(dirp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +467,7 @@ CopyCheckDeletePermission(
|
||||||
#else
|
#else
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
#endif
|
#endif
|
||||||
char fname[1024];
|
char fname[PATH_MAX];
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
if (statfs(parentdir,&statbuf) < 0) /* does not exist */
|
if (statfs(parentdir,&statbuf) < 0) /* does not exist */
|
||||||
|
@ -483,19 +491,34 @@ CopyCheckDeletePermission(
|
||||||
char *tmpfile;
|
char *tmpfile;
|
||||||
int rv;
|
int rv;
|
||||||
tmpfile = tempnam(parentdir,"dtfile");
|
tmpfile = tempnam(parentdir,"dtfile");
|
||||||
if ( (rv = creat(tmpfile,O_RDONLY)) < 0) /* Create a temporary file */
|
if (tmpfile)
|
||||||
return -1;
|
{
|
||||||
close(rv);
|
/* Create a temporary file */
|
||||||
if (remove(tmpfile) < 0) /* Delete the created file */
|
if ( (rv = creat(tmpfile,O_RDONLY)) < 0)
|
||||||
return -1;
|
{
|
||||||
|
free(tmpfile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close(rv);
|
||||||
|
/* Delete the created file */
|
||||||
|
if (remove(tmpfile) < 0)
|
||||||
|
{
|
||||||
|
free(tmpfile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(tmpfile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* root user can delete anything */
|
/* root user can delete anything */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for write and execute permisssion on parent dir */
|
/* check for read/write and execute permission on parent dir */
|
||||||
if (access(parentdir, 04|02 | 01) < 0)
|
if (access(parentdir, R_OK | W_OK | X_OK) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* copy destinationPath to tmp buffer */
|
/* copy destinationPath to tmp buffer */
|
||||||
|
@ -531,7 +554,7 @@ CheckDeleteAccess(
|
||||||
|
|
||||||
delay = 10000;
|
delay = 10000;
|
||||||
tmpptr = strrchr(tmpstring,'/');
|
tmpptr = strrchr(tmpstring,'/');
|
||||||
if(!tmpptr) /* Error */
|
if(!tmpstring || !tmpptr) /* Error */
|
||||||
perm_status = 1;
|
perm_status = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -546,7 +569,10 @@ CheckDeleteAccess(
|
||||||
free(tmpstring);
|
free(tmpstring);
|
||||||
}
|
}
|
||||||
if(!perm_status) /* Everything is fine just return */
|
if(!perm_status) /* Everything is fine just return */
|
||||||
return;
|
{
|
||||||
|
free(tmpstring);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(title,GETMESSAGE(4,7,"Object Trash - Error"));
|
strcpy(title,GETMESSAGE(4,7,"Object Trash - Error"));
|
||||||
tmpmsg = GETMESSAGE(4,8,"You do not have permission to put the object \n\n%s\n\ninto trash.\n\nUse the Change Permissions choice from the object's\npopup menu or from the Selected menu to turn on your\nRead permission on the object.\n\nNote: If this object is a folder, you must also have\nRead permission for each of the objects inside the\nfolder before you can put the folder in the trash.");
|
tmpmsg = GETMESSAGE(4,8,"You do not have permission to put the object \n\n%s\n\ninto trash.\n\nUse the Change Permissions choice from the object's\npopup menu or from the Selected menu to turn on your\nRead permission on the object.\n\nNote: If this object is a folder, you must also have\nRead permission for each of the objects inside the\nfolder before you can put the folder in the trash.");
|
||||||
|
@ -566,6 +592,8 @@ CheckDeleteAccess(
|
||||||
XtAppNextEvent(app_context, &event);
|
XtAppNextEvent(app_context, &event);
|
||||||
XtDispatchEvent(&event);
|
XtDispatchEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(tmpstring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,18 +608,9 @@ TimeoutHandler(XtPointer client_data, XtIntervalId *id)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
#ifdef _NO_PROTO
|
_DtCopyPathFromInput(char *input_string, char *current_dir)
|
||||||
_DtCopyPathFromInput(input_string, current_dir)
|
|
||||||
char *input_string;
|
|
||||||
char *current_dir;
|
|
||||||
#else
|
|
||||||
_DtCopyPathFromInput(
|
|
||||||
char *input_string,
|
|
||||||
char *current_dir)
|
|
||||||
#endif /* _NO_PROTO */
|
|
||||||
|
|
||||||
{
|
{
|
||||||
char *path;
|
char *path = NULL;
|
||||||
char *tmp_path = NULL;
|
char *tmp_path = NULL;
|
||||||
int dir_len;
|
int dir_len;
|
||||||
char *_DtCopyChangeTildeToHome();
|
char *_DtCopyChangeTildeToHome();
|
||||||
|
@ -616,13 +635,21 @@ _DtCopyPathFromInput(input_string, current_dir)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fscanf(pfp,"%s",command);
|
if (fscanf(pfp,"%s",command) >= 1)
|
||||||
XtFree(path);
|
{
|
||||||
path = XtNewString(command);
|
XtFree(path);
|
||||||
|
path = XtNewString(command);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
path = NULL;
|
||||||
|
|
||||||
pclose(pfp);
|
pclose(pfp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
/* Resolve '~' -- new memory is allocated, old memory is freed */
|
/* Resolve '~' -- new memory is allocated, old memory is freed */
|
||||||
if (*path == '~')
|
if (*path == '~')
|
||||||
path = _DtCopyChangeTildeToHome(path);
|
path = _DtCopyChangeTildeToHome(path);
|
||||||
|
@ -750,19 +777,9 @@ _DtCopyChangeTildeToHome (input_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
#ifdef _NO_PROTO
|
Check(char *spth, char *dpth, int mode)
|
||||||
Check( spth,dpth, mode)
|
|
||||||
register char *spth ;
|
|
||||||
register char *dpth ;
|
|
||||||
int mode ;
|
|
||||||
#else
|
|
||||||
Check(
|
|
||||||
register char *spth,
|
|
||||||
register char *dpth,
|
|
||||||
int mode)
|
|
||||||
#endif /* _NO_PROTO */
|
|
||||||
{
|
{
|
||||||
struct stat sbuf,dbuf;
|
struct stat sbuf, dbuf;
|
||||||
char filename [MAX_PATH];
|
char filename [MAX_PATH];
|
||||||
char * msg;
|
char * msg;
|
||||||
char * tmpStr;
|
char * tmpStr;
|
||||||
|
@ -784,6 +801,8 @@ Check( spth,dpth, mode)
|
||||||
strcpy(title,GETMESSAGE(4,5,"Object Move - Error"));
|
strcpy(title,GETMESSAGE(4,5,"Object Move - Error"));
|
||||||
else
|
else
|
||||||
strcpy(title,GETMESSAGE(4,6,"Object Copy - Error"));
|
strcpy(title,GETMESSAGE(4,6,"Object Copy - Error"));
|
||||||
|
|
||||||
|
dbuf.st_ino = 0;
|
||||||
while (dbuf.st_ino != ROOTINO)
|
while (dbuf.st_ino != ROOTINO)
|
||||||
{
|
{
|
||||||
/* Destination may not be available, in which case we need to
|
/* Destination may not be available, in which case we need to
|
||||||
|
|
Loading…
Reference in a new issue