Exemple #1
0
void DoExtDiskSpace(tBuffer *bIn, tBuffer *bOut, u_int32_t id)
{
	struct STATFS stfs;
	tFSPath	*realPath;
	char *path;

	path = convertFromUtf8(BufferGetString(bIn), 1);
	realPath = FSCheckPath(path);
	DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH]Path: %s", path));
	if (realPath != NULL && !HAS_BIT(gl_var->flagsDisable, SFTP_DISABLE_STATSFS))
	{
		DEBUG((MYLOG_DEBUG, "[DoExtDiskSpaceOpenSSH]Realpath: %s", realPath->realPath));
		if (STATFS(realPath->realPath, &stfs) == 0)
		{
			tBuffer *b;

			b = BufferNew();
			BufferPutInt8(b, SSH2_FXP_EXTENDED_REPLY);
			BufferPutInt32(b, id);
			BufferPutInt64(b, (u_int64_t) stfs.f_blocks * (u_int64_t) stfs.f_bsize);
			BufferPutInt64(b, (u_int64_t) stfs.f_bfree * (u_int64_t) stfs.f_bsize);
			BufferPutInt64(b, 0);
			BufferPutInt64(b, (u_int64_t) stfs.f_bavail * (u_int64_t) stfs.f_bsize);
			BufferPutInt32(b, stfs.f_bsize);
			BufferPutPacket(bOut, b);
		}
		else
			SendStatus(bOut, id, errnoToPortable(errno));
	}
	else
		SendStatus(bOut, id, SSH2_FX_PERMISSION_DENIED);
	FSDestroyPath(realPath);
	free(path);
}
void DoExtHardLink(tBuffer *bIn, tBuffer *bOut, u_int32_t id)
{
	char *link, *target;
	int status = SSH2_FX_OK;

	link = convertFromUtf8(BufferGetString(bIn), 1);
	target = convertFromUtf8(BufferGetString(bIn), 1);
	if (HAS_BIT(gl_var->flagsDisable, SFTP_DISABLE_SYMLINK))
	{
		DEBUG((MYLOG_DEBUG, "[DoExtHardLink]Disabled by conf."));
		status = SSH2_FX_PERMISSION_DENIED;
	}
	else
	{
		status = FSHardlink(target, link);
		DEBUG((MYLOG_DEBUG, "[DoExtHardLink]link:'%s' target:'%s' -> %i", link, target, status));
	}
	SendStatus(bOut, id, status);
	free(target);
	free(link);
}