{"action":"created","issue":{"url":"https://api.github.com/repos/freebsd/pkg/issues/1222","repository_url":"https://api.github.com/repos/freebsd/pkg","labels_url":"https://api.github.com/repos/freebsd/pkg/issues/1222/labels{/name}","comments_url":"https://api.github.com/repos/freebsd/pkg/issues/1222/comments","events_url":"https://api.github.com/repos/freebsd/pkg/issues/1222/events","html_url":"https://github.com/freebsd/pkg/issues/1222","id":66597425,"number":1222,"title":"Unprivileged user can make pkg add/install/delete fail","user":{"login":"stesser","id":6264546,"avatar_url":"https://avatars.githubusercontent.com/u/6264546?v=3","gravatar_id":"","url":"https://api.github.com/users/stesser","html_url":"https://github.com/stesser","followers_url":"https://api.github.com/users/stesser/followers","following_url":"https://api.github.com/users/stesser/following{/other_user}","gists_url":"https://api.github.com/users/stesser/gists{/gist_id}","starred_url":"https://api.github.com/users/stesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stesser/subscriptions","organizations_url":"https://api.github.com/users/stesser/orgs","repos_url":"https://api.github.com/users/stesser/repos","events_url":"https://api.github.com/users/stesser/events{/privacy}","received_events_url":"https://api.github.com/users/stesser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2015-04-06T12:40:06Z","updated_at":"2016-06-25T15:26:05Z","closed_at":null,"body":"I had alreday described this issue for pkg-1.3.8 as of 2014-12-04, but the problem exists with the lastest pkg-devel, too. \r\n\r\nThis problem is not fully reproducible in the sense, that it occurs and persists when retrying in a certain state of the installed ports and ports needing to be rebuilt, while portsmaster builds hundreds of ports without this problem on other days. (I.e., if it fails once, repeating the portmaster command will again lead to the same error abort for any number of repeated attempts.)\r\n\r\nI'm pasting my mail from 4 months ago (to the ports@freebsd.org and pkg@freebsd.org lists), since it contains all relevant details. (Sorry for the ugly formatting as a result of Markdown interpretation of mail elements - I have no idea how to insert quoted text that is not subject to mangling ...)\r\n\r\n****************************************************\r\nHi all,\r\n\r\nI've been having problems with portmaster being aborted because of\r\nfailed attempts of pkg to obtain a lock. The same problem occurs\r\nwith pkg and pkg-devel (I installed pkg-devel to check whether it\r\nwas due to an already fixed problem in pkg-1.3.8).\r\n\r\nOther possibly relevant machine details: -CURRENT/amd64 on ZFS.\r\n\r\n\r\nA typical portmaster/pkg error message is:\r\n\r\n--------------------------------------------------------------------\r\n===>>> Creating a backup package for old version cuse4bsd-kmod-0.1.35\r\nCreating package for cuse4bsd-kmod-0.1.35\r\npkg: Cannot get an advisory lock on a database, it is locked by another\r\nprocess\r\n\r\n===>  Installing for cuse4bsd-kmod-0.1.35\r\n===>  Checking if cuse4bsd-kmod already installed\r\n===>   cuse4bsd-kmod-0.1.35 is already installed\r\n      You may wish to ``make deinstall'' and install this port again\r\n      by ``make reinstall'' to upgrade it properly.\r\n      If you really wish to overwrite the old port of cuse4bsd-kmod\r\n      without deleting it first, set the variable \"FORCE_PKG_REGISTER\"\r\n      in your environment or the \"make install\" command line.\r\n*** Error code 1\r\n\r\nStop.\r\nmake[1]: stopped in /usr/svn/ports/head/multimedia/cuse4bsd-kmod\r\n[...]\r\n--------------------------------------------------------------------\r\n\r\nIn all these cases it was just portmaster that was using pkg, no other\r\nprocess could have held a lock. (BTW: This was with \"portmaster -dgw\",\r\nI have not checked whether other options hide this problem ...)\r\n\r\n\r\nI have further debugged this problem and found, that the locking\r\nproblem occurs during this command from /usr/ports/mk/bsd.openssl.mk:\r\n\r\nOPENSSL_SHLIBFILE!=     ${PKG_INFO} -ql ${OPENSSL_INSTALLED} | grep\r\n\"^`pkg query \"%p\" ${OPENSSL_INSTALLED}`/lib/libcrypto.so.[0-9]*$$\"\r\n\r\n(sorry about possible line-wrap - this should be a single line ...)\r\n\r\nThis command on its own can be executed without problems:\r\n\r\n# pkg info -ql openssl | grep `pkg query %p openssl`/lib/libcrypto.so.*\r\n/usr/local/lib/libcrypto.so.8\r\n\r\nBut when it is run in parallel to portmaster creating a package, that\r\nprocess can not acquire the necessary lock and portmaster aborts.\r\n\r\nThis problem does only occur, if portmaster runs a background task\r\nthat parses bsd.openssl.mk (and it appears that every time this file\r\nis read by \"make\", the pkg-grep-pkg command sequence is invoked).\r\n(It seems to be due to a \"make -V\" in some other port's directory,\r\nwhich has a \".include bsd.openssl.mk\", which is executed by portmaster\r\nin preparation of building the next port, but I have not identified\r\nthe exact line in portmaster that does that.)\r\n\r\nI have no other work-around than to manually install the affected\r\nports.\r\n\r\nAnyway: While it seems that this is a problem in portmaster, I still\r\nthink that multiple invocations of \"pkg info\" or \"pkg query\" at the\r\ntime a \"pkg create\" is running should not make the latter fail ...\r\n\r\nRegards, STefan\r\n\r\nPS: I'm supprised this problem has not been reported on the mail-lists,\r\n    since it is unlikely to only affect me. I'll do a search in the PRs\r\n    and create a new PR if I really cannot find an existing one ...\r\n'''\r\n"},"comment":{"url":"https://api.github.com/repos/freebsd/pkg/issues/comments/228550484","html_url":"https://github.com/freebsd/pkg/issues/1222#issuecomment-228550484","issue_url":"https://api.github.com/repos/freebsd/pkg/issues/1222","id":228550484,"user":{"login":"stesser","id":6264546,"avatar_url":"https://avatars.githubusercontent.com/u/6264546?v=3","gravatar_id":"","url":"https://api.github.com/users/stesser","html_url":"https://github.com/stesser","followers_url":"https://api.github.com/users/stesser/followers","following_url":"https://api.github.com/users/stesser/following{/other_user}","gists_url":"https://api.github.com/users/stesser/gists{/gist_id}","starred_url":"https://api.github.com/users/stesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stesser/subscriptions","organizations_url":"https://api.github.com/users/stesser/orgs","repos_url":"https://api.github.com/users/stesser/repos","events_url":"https://api.github.com/users/stesser/events{/privacy}","received_events_url":"https://api.github.com/users/stesser/received_events","type":"User","site_admin":false},"created_at":"2016-06-25T15:26:05Z","updated_at":"2016-06-25T15:26:05Z","body":"What is the largest result that is to be expected?\r\nFor single line queries of 3000 packages (packaged base plus more than 2000 ports) and some 100 bytes of query result per line, the output could easily be stored on the heap (a few hundred KB).\r\nMulti-line queries have enough overhead for each port (multiple database accesses per port) to allow buffering of results for each port and to release the shared lock after data for each port have been fetched."}}
{"actor":{"display_login":"stesser"}}