在非管理员 Mac 上更改 RealBASIC 权限

发布于 2024-09-30 12:28:15 字数 551 浏览 2 评论 0原文

我的应用程序需要将文件写入(并移动)到非管理员用户的文件夹中,并且该用户无权使用该文件夹。

我尝试更改该文件夹的权限,但似乎没有效果。

是否存在允许我这样做的内置限制?

我所做的就是写入文档,然后尝试将文件移动到最终文件夹,但失败了......

感谢您的回答!

这是代码:

  Dim t as TextOutputStream
  Dim tempfile as FolderItem = SpecialFolder.Documents.Child(filePath.Name)

  t = tempfile.CreateTextFile
  t.Write fileData
  t.close

  Dim p as New Permissions( 0 )

  p.OthersExecute = True
  p.OthersWrite = True
  p.OthersRead = True

  filePath.Parent.Permissions = p

  tempfile.MoveFileTo filePath.Parent

My app needs to write (and move) files to a folder from a non-admin user, and that user has no permission to use that folder.

I tried changing the permissions for the folder but it doesn't appear to have an effect.

Are there built-in restrictions from allowing me to do that?

What I do is write to Documents and then attempt to move file to final folder, which fails...

Thanks for any answers!

Here is the code:

  Dim t as TextOutputStream
  Dim tempfile as FolderItem = SpecialFolder.Documents.Child(filePath.Name)

  t = tempfile.CreateTextFile
  t.Write fileData
  t.close

  Dim p as New Permissions( 0 )

  p.OthersExecute = True
  p.OthersWrite = True
  p.OthersRead = True

  filePath.Parent.Permissions = p

  tempfile.MoveFileTo filePath.Parent

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆凄美了谁 2024-10-07 12:28:15

该操作系统旨在阻止此类事情,否则这是一个巨大的安全漏洞

The OS is designed to STOP this sort of thing as it's a huge security hole otherwise

伊面 2024-10-07 12:28:15

您可以使用 Monkeybread Software 插件 AuthorizationMBS 中的功能之一来允许授权,假设用户可以提升安全级别。在我的一个必须进入系统位置的类中,我有这个:

Protected Function mbsAuthorize() As boolean
  dim a as AuthorizationMBS
  dim s(2) as String

  if mbsAuthorized then
    mbsForm = mbsAuth.ExternalForm
    Return true
  else
    a = New AuthorizationMBS
    If a.NewAuthorization(nil, a.kAuthorizationFlagPreAuthorize) Then
      a.SimpleAuthorize

      if a.Authorized then
        mbsAuth=a // save so the externalform doesn't get invalid
        mbsForm=a.ExternalForm // copy to string for later use.
        Return true
      end if
    else
      break
    End if
  end

  return false
End Function

该类具有以下属性:

mbsForm 作为字符串

mbsAuth 作为 AuthorizationMBS

You could use one of the functions in the Monkeybread Software plugin, AuthorizationMBS, to allow authorization, assuming the user can elevate the security level. In a class of mine that has to get into a System location, I have this:

Protected Function mbsAuthorize() As boolean
  dim a as AuthorizationMBS
  dim s(2) as String

  if mbsAuthorized then
    mbsForm = mbsAuth.ExternalForm
    Return true
  else
    a = New AuthorizationMBS
    If a.NewAuthorization(nil, a.kAuthorizationFlagPreAuthorize) Then
      a.SimpleAuthorize

      if a.Authorized then
        mbsAuth=a // save so the externalform doesn't get invalid
        mbsForm=a.ExternalForm // copy to string for later use.
        Return true
      end if
    else
      break
    End if
  end

  return false
End Function

The class has these properties:

mbsForm as string

mbsAuth as AuthorizationMBS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文