Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Deleting a npm package throws a UnauthorizedAccessException

    Scheduled Pinned Locked Moved Support
    progetnpmwindows
    9 Posts 1 Posters 19 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      We've been using ProGet for several months now and we ran into this exception trying to delete any npm package. Pushing new npm packages works just fine. Deleting nuget packages also works. Our ProGet server is hosted as a Windows Service.

      See the exception details below.

      Server Error in '/' Application.
      Access to the path 'H:\ProGet\Packages\.npm\F2\our-package\2.2.3\package.tgz' is denied.
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
      
      Exception Details: System.UnauthorizedAccessException: Access to the path 'H:\ProGet\Packages\.npm\F2\our-package\2.2.3\package.tgz' is denied. 
      
      ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 
      
      To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
      
      Source Error: 
      
      An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
      
      Stack Trace: 
      
      
      [UnauthorizedAccessException: Access to the path 'H:\ProGet\Packages\.npm\F2\our-package\2.2.3\package.tgz' is denied.]
         System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +417
         System.IO.File.InternalDelete(String path, Boolean checkHost) +14691099
         Inedo.IO.FileEx.Delete(String path) +93
         Inedo.ProGet.Extensions.FileSystems.DirectoryFileSystem.DeleteFileAsync(String fileName) +17
         Inedo.ProGet.Feeds.Npm.<DeletePackageAsync>d__15.MoveNext() +349
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         Inedo.ProGet.WebApplication.Pages.Npm.Packages.<<CreateChildControls>b__15_0>d.MoveNext() +305
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         Inedo.Web.PageFree.<ProcessPostAsync>d__62.MoveNext() +522
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         Inedo.Web.PageFree.<ProcessPostAsync>d__62.MoveNext() +798
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         Inedo.Web.PageFree.<ProcessRequestAsync>d__46.MoveNext() +575
         System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
         System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
         System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +59
         Inedo.Web.Handlers.AsyncHandlerWrapper.EndProcessRequest(IAsyncResult result) +33
         System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +618
         System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
         System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
      

      Product: ProGet
      Version: 5.1.22

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        Is the ProGet service running as a user with admin privileges? Does that user have permission to delete files from H:\ProGet\Packages.npm? Is this IIS hosted?

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          This is not IIS hosted, it is running as a Windows Service. When I open up Task Manager, it is running as a Network Service. My understanding is that user should have the ability to delete those files. All of the ProGet folders, including both the NPM and Nuget folders, have the same file permissions. However, NPM packages are the only packages throwing this exception.

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            What about the permission on the tgz files themselves? The process that publishes them may grant insufficient privileges to delete. Can you manually delete the .tgz?

            1 Reply Last reply Reply Quote 0
            • ? This user is from outside of this forum
              Guest
              last edited by

              Here are the permissions of a .tgz compared to the permissions the .nupkg are receiving.

              Image Text

              1 Reply Last reply Reply Quote 0
              • ? This user is from outside of this forum
                Guest
                last edited by

                Sorry, previous post was attached incorrectly.

                Image Text

                1 Reply Last reply Reply Quote 0
                • ? This user is from outside of this forum
                  Guest
                  last edited by

                  Nothing stands out there. Did you try what was suggested in the error output?

                  "ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

                  To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access."

                  The ProGet Windows service was installed as an Integrated Web Server since it is not IIS.

                  1 Reply Last reply Reply Quote 0
                  • ? This user is from outside of this forum
                    Guest
                    last edited by

                    I ended up working around this by elevating ProGet Service and ProGet Web Server to run under the "Local System" account instead of "Network Service". This is effectively elevating ProGet to root. Not great that I had to do this because something is broken with the default installation permissions and settings.

                    1 Reply Last reply Reply Quote 0
                    • ? This user is from outside of this forum
                      Guest
                      last edited by

                      You got it working though :)

                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • 1 / 1
                      • First post
                        Last post
                      Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation