Code Monkey home page Code Monkey logo

py-kms's People

Contributors

angrynoodlez avatar arturolegovich avatar atensi avatar bruor avatar creeperkong avatar dependabot[bot] avatar edgd1er avatar edgeyboy avatar gh0st-app1e avatar jacobite89 avatar lepoarro avatar matthew-beckett avatar michelbaie avatar plazotronik avatar pvgoran avatar saltspork avatar sashaqwert avatar seia-soto avatar simonmicro avatar solor1 avatar speedst3r avatar systemrage avatar taknok avatar thedevfreak avatar thespad avatar vosdev avatar xwtf avatar yangzhaofeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-kms's Issues

Taking a long time for Docker container to stop

$ time docker stop py-kms
py-kms

________________________________________________________
Executed in   10.21 secs      fish           external
   usr time   15.06 millis    0.00 micros   15.06 millis
   sys time    6.14 millis  282.00 micros    5.86 millis

Maybe the stop signal is incorrect or needs to be setup properly in the application code?

Docker says time is mismatched

Recently setup Py-KMS in docker and noticed this when looking at logs. I have another py-kms LXC in proxmox and have no such warnings. I can provide more info if needed. I checked date and time and both are correct though maybe a minuet or so apart.

Thu, 07 Apr 2022 18:56:20 WARNING Okay, something went horribly wrong while localizing the request time (proceeding anyways): Timezone offset does not match system offset: 0 != -14400. Please, check your config files.
Thu, 07 Apr 2022 18:56:20 WARNING With count = 26, activated client could be detected as not genuine !

Support sending LOGFILE argument to stdout for better container compatability

Currently in pykms_Misc.py at line 230, there is a snippet of code that validates the value passed in via LOGFILE has the extension .log.

In container runtimes such as containerd/Docker the runtime provides /dev/stdout as the pipe to send container logs to which can then be viewed via mechanisms such as docker logs.

I am proposing the removal of this assertion as in *nix environments the extension is irrelevant. Removal of this snippet would allow users the ability to provide paths such as /dev/stdout as the destination for log outputs from within the application.

Can't install pysqlite3 On Ubuntu 22 server

Hi there ...
I'm trying to install py-kms on ubuntu server for multiple purposes and seems I can't manage to install pysqlite3 using the mentioned code.
sudo pip3 install tzlocal pysqlite3
Which Let's the tzlocal to install completely but retuned error on installing pysqlite3.
I'm using python3 as mentioned in dependencies and here is the result.

Collecting tzlocal
  Downloading tzlocal-4.2-py3-none-any.whl (19 kB)
Collecting pysqlite3
  Downloading pysqlite3-0.4.7.tar.gz (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.1/40.1 KB 610.2 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting pytz-deprecation-shim
  Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
Collecting tzdata
  Downloading tzdata-2022.6-py2.py3-none-any.whl (338 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 338.8/338.8 KB 1.0 MB/s eta 0:00:00
Building wheels for collected packages: pysqlite3
  Building wheel for pysqlite3 (setup.py) ... done
  WARNING: Legacy build of wheel for 'pysqlite3' created no files.
  Command arguments: /usr/bin/python3 -u -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize

  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)

  __file__ = %r
  sys.argv[0] = __file__

  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"

  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'/tmp/pip-install-aabw3cmr/pysqlite3_da46b2b535274bcabf8df25c3afcbf12/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d /tmp/pip-wheel-9z4yuwq8
  Command output: [use --verbose to show]
  Running setup.py clean for pysqlite3
Failed to build pysqlite3
Installing collected packages: pysqlite3, tzdata, pytz-deprecation-shim, tzlocal
  Running setup.py install for pysqlite3 ... done
Successfully installed pysqlite3 pytz-deprecation-shim-0.1.0.post0 tzdata-2022.6 tzlocal-4.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Please sir do kindly let me know if I am doing something wrong according to your readme page, or is there any replacement for pysqlite3.

Thanks!

Issue with server listening on IPv6

Here is the issue i can run on specific IPv4 & IPv6 and it will work (for example: ./pykms_Server.py ::1 1688 - will listen on loopback interface ip v6 ::1 and ./pykms_Server.py 127.0.0.1 1688 - will listen on loopback interface ip v4 127.0.0.1), but as it stands right now there is no way to use both at the same time (dual stack), because for IP it only takes only 1 argument. Also default option (0.0.0.0), only listens on all interfaces IPv4 only and skips IPv6 listening... sure i could run 2 pykms_Server instances both listening on different ips, but it shouldnt be that hard, also since i run py-kms in docker, i would need to run 2 py-kms docker containers or write my own...

Would be nice to have ability, to set server to listen on multiple ips in the same instance and have default option to listen on all ipv4 and ipv6 addresses on all interfaces.

Feature request : Support Server 2003 and XP

For the sake of completeness, is it possible to support XP and 2003 (R2) ?

These system are loved for running old software, and official activation methods are harder to use over time for these old operating system.
Unofficial methods documentation gets lost (links are now 404). The cleanest way would be to use slmgr.vbs /skms

Of course, I do not recommend running these system on something else than an air gaped network without internet.

Not activating

Receiving the following when attempting to activate Windows server 2022 after pulling latest python3 image.

Wed, 13 Oct 2021 10:25:29 INFO Machine Name: xxx
Wed, 13 Oct 2021 10:25:29 INFO Client Machine ID: a1597c43-9243-4160-83f4-a1b4ff788ee7
Wed, 13 Oct 2021 10:25:29 INFO Application ID: Windows
Wed, 13 Oct 2021 10:25:29 INFO SKU ID: ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae03
Wed, 13 Oct 2021 10:25:29 INFO License Status: Notifications Mode
Wed, 13 Oct 2021 10:25:29 INFO Request Time: 2021-10-13 14:25:28 (UTC)
Wed, 13 Oct 2021 10:25:29 ERROR Sqlite Error: no such table: clients. Exiting...
Wed, 13 Oct 2021 10:25:29 INFO Connection closed: 192.168.1.13:49709

Error: 0x8007232B DNS name does not exist

I'm running pykmsorg/py-kms:python3 in my local IPv4 only network. Trying to activate Windows 10 Pro with a GVLK Key.

> nslookup -type=srv _vlmcs._tcp
Server:  *my DNS server hostname*
Address:  *my DNS server IP*

_vlmcs._tcp     SRV service location:
          priority       = 20
          weight         = 0
          port           = 1688
          svr hostname   = *my container hostname*
kms.example.com     internet address = *my container IP*

> Test-NetConnection *my container hostname* -Port 1688
ComputerName     : *my container hostname*
RemoteAddress    : *my container IP*
RemotePort       : 1688
InterfaceAlias   : *my adapter name*
SourceAddress    : *my computer IP*
TcpTestSucceeded : True

However, slmgr /ato produces this error: Error: 0x8007232B DNS name does not exist.

Settings -> Activation has this text in red:

We can’t activate Windows on this device as we can’t connect to your organization’s activation server. Make sure that you’re connected to your organization’s network and try again. If you continue having problems with activation, contact your organization’s support person. Error code: 0x8007007B

Is it a problem with py-kms or my network? What am I doing wrong?

Py-KMS on Python Version 3.10 not working

Hello

I want to use py-kms for my homelab test but cannot start the service

here step by step what i have done

py pip install tzlocal pysqlite3
  • Unzipped py-kms-master.zip at C:\KMS\
  • checking if python works correctly : OK
c:\KMS\py-kms>py
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
  • try to start pykms_Server.py and get an error
c:\KMS\py-kms>py pykms_Server.py
Traceback (most recent call last):
  File "c:\KMS\py-kms\pykms_Server.py", line 27, in <module>
    from Etrigan import Etrigan, Etrigan_parser, Etrigan_check, Etrigan_job
  File "c:\KMS\py-kms\Etrigan.py", line 12, in <module>
    from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (C:\Program Files\Python310\lib\collections\__init__.py)

c:\KMS\py-kms>

I would like to get some help to know if i missed one step

thanks you in advance

"latest" update not working

I was running my py-kms (docker) on UNRAID server and now after latest update it stopped working.
This is the error what was shown:
Traceback (most recent call last): File "/usr/bin/entrypoint.py", line 28, in <module> enableSQLITE = os.environ.get('SQLITE').lower() == 'true' AttributeError: 'NoneType' object has no attribute 'lower' Traceback (most recent call last): File "/usr/bin/entrypoint.py", line 28, in <module> enableSQLITE = os.environ.get('SQLITE').lower() == 'true' AttributeError: 'NoneType' object has no attribute 'lower' Traceback (most recent call last): File "/usr/bin/entrypoint.py", line 28, in <module> enableSQLITE = os.environ.get('SQLITE').lower() == 'true' AttributeError: 'NoneType' object has no attribute 'lower'
Need to get it working again!!! Please!

Docker container not dropping privileges

Docker container does not drop privileges and runs py-kms as root when started with docker compose in the following manner:

version: "3.9"

services:
  app:
    image: pykmsorg/py-kms:minimal
    ports:
      - 1688:1688
    volumes:
      - /etc/localtime:/etc/localtime:ro

The issue is also present when started with the way mentioned in README (docker run -d --name py-kms --restart always -p 1688:1688 ghcr.io/py-kms-organization/py-kms) and seems to be not related to docker itself but rather to entrypoint.py.

The following code

uid = int(user_db_entries.pw_uid)
gid = int(user_grp_db_entries.gr_gid)
new_gid = int(os.getenv('GID', str(gid)))
new_uid = int(os.getenv('UID', str(uid)))
gets UID/GID from environment variables UID and GID. If they are not present, os.getenv() uses default values, making new_uid and new_gid equal to uid and gid, rendering checks
if gid != new_gid:
and
if uid != new_uid:
false, thus os.setuid() and os.setgid() are not called.

I need mysql datastore for many py-kms instances

Sqlite is for one instanse on k8s or one-docker-node. Who want write code for sqlite and mysql ?

Who can do this? many py-kms instances can work only with Lan-DB (postgres, mysql, etc.) not with sqlite

Error while activating 0x80070000d

kms actication the data is invalid 0x80070000d
im getting this error while trying to run my server on my local network (docker) and trying to activate on the same network.

i do know that it happens because i run server and client on the same computer and running the server on virtualbox fixed my issue

however,

  • i think docker can do bridge networking by himself * (without virtualbox).

so the question is: how to run server and client on the same computer using docker?

py-kms Module 'tzlocal' or 'pytz' not available !

Hello,

When I run the server like this:
python3 pykms_Server.py 192.168.0.100 1688

Then try to activate from the Windows Client like this:
slmgr /ato

I get this warning in the Server output but it still activates anyway...
py-kms Module 'tzlocal' or 'pytz' not available ! Request time not localized

A similar issue was reported to the SystemRage py-kms GitHub and they seemed to make a fix to around Line 164 of ../KMS/py-kms/py-kms/pykms_Server.py That fix is, I think, still in the code in that file on the Py-KMS-Organization GitHub but the error has returned.

Any ideas what is going wrong there and how to eliminate that warning?

Cheers,

Flex

[Docker] Multiple IPs in environment var causes failure to start server when using SQLite

The change in #61 causes the server to fail to launch due to command syntax - the SQLite parameters get added after the connect statement.

Sat, 21 Jan 2023 12:40:46 INFO     Setting gid to '100'.
Sat, 21 Jan 2023 12:40:46 INFO     Setting uid to '100'.
Sat, 21 Jan 2023 12:40:46 INFO     Storing database file to /home/py-kms/db/pykms_database.db
unrecognized optional connect arguments: `-s`. Exiting...

I modified the start.py script to move the connect statement after the SQLite parameters and the server starts without issue.

  if enableSQLITE:
    loggersrv.info("Storing database file to %s" % dbPath)
    command.append('-s')
    command.append(dbPath)
    os.makedirs(os.path.dirname(dbPath), exist_ok=True)

  if len(listen_ip) > 1:
    command.append("connect")
    for i in range(1, len(listen_ip)):
      command.append("-n")
      command.append(listen_ip[i] + "," + listen_port)
      command.append("-d")

Can this be replicated, confirmed and start script modified for future container builds?

Server 2022 KMSItem

I see Server 2022 is shown as supported, but I do not see any XML entries for it in the KmsDataBase.xml file.

Using Google Colab and ngrok to serve it temporarily

I have tried following to serve and activate using ngrok in google colab but I am not getting it work. I have changed http to tcp.

Setup Google Colab

  1. Visit https://colab.research.google.com/
  2. Sign in / Sign up using google account
  3. Create new note book

Get authorised ngrok tunnel

  1. Download ngrok Google Colab
!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
  1. Unzip
!unzip ngrok-stable-linux-amd64.zip
  1. Sign up at ngrok and get authtoke
!./ngrok authtoken <your-auth-token>
  1. Start ngrok and python kms server
!./ngrok tcp 8081 & python3 /content/py-kms/py-kms/pykms_Server.py 0.0.0.0 8081

Thanks for maintaining the project

Add to README.md

We need added to README.md, that py-kms is like Microsoft KMS-server, but not for production use, testing for self)

Commands for office 2021

I Already installed the kms server..Does anyone here can share with me the commands to be used on cmd to activate office 2021. I cant find in the docs..

Office Professional 2021 Volume License

Tried the Office 2021 Build and it would not Activate Office 2021
Im not a coder and not sure if this is correct but I can now Activate Office 2021 with these changes.

File: KmsDataBase.xml
Line 533: Change
<CsvlkItem DisplayName="Office 2021" VlmcsdIndex="6" GroupId="206" MinKeyId="571000000" MaxKeyId="590999999" IniFileName="Office2021" EPid="05426-00206-586-025264-03-1033-9200.0000-2602021" Id="47f3b983-7c53-4d45-abc6-bcd91e2dd90a" InvalidWinBuild="[0,1]">

Line 991: Change
<KmsItem DisplayName="Office 2021" Id="86d50b16-4808-41af-b83b-b338274318b2" CanMapToDefaultCsvlk="false" DefaultKmsProtocol="6.0" NCountPolicy="5">

Hope that helps someone.
Larry

pytz missing

There is message error in the log: kms | Thu, 16 Sep 2021 05:17:00 WARNING Module 'tzlocal' not available ! Request time not localized.
Here is the code triggering the warning
pykms_Base L123: from pytz.exceptions import UnknownTimeZoneError
L131: except ImportError: .....

Adding the pytz package (pip3 install pytz), whatever is the timezone, I have that error. I can't see why it is related.ere
Is there any reason ?

kms       | Traceback (most recent call last):
kms       |   File "pykms_Client.py", line 364, in <module>
kms       |     clt_main(with_gui = False)
kms       |   File "pykms_Client.py", line 280, in clt_main
kms       |     client_create(clt_sock)
kms       |   File "pykms_Client.py", line 240, in client_create
kms       |     parsed = MSRPCRespHeader(response)
kms       |   File "/home/py-kms/pykms_Dcerpc.py", line 641, in __init__
kms       |     MSRPCHeader.__init__(self, aBuffer, alignment)
kms       |   File "/home/py-kms/pykms_Dcerpc.py", line 588, in __init__
kms       |     Structure.__init__(self,data, alignment)
kms       |   File "/home/py-kms/pykms_Structure.py", line 117, in __init__
kms       |     self.fromString(data)
kms       |   File "/home/py-kms/pykms_Structure.py", line 174, in fromString
kms       |     self[field[0]] = self.unpack(field[1], data[:size], dataClassOrCode=dataClassOrCode, field=field[0])
kms       |   File "/home/py-kms/pykms_Structure.py", line 336, in unpack
kms       |     return self.unpack(two[0], data)
kms       |   File "/home/py-kms/pykms_Structure.py", line 392, in unpack
kms       |     return unpack(format, b(data))[0]
kms       | struct.error: ('unpack requires a buffer of 1 bytes', "When unpacking field 'ver_major | B=5 | ''[:1]'")

Windows kms error

When trying to run slmgr.vbs /ato after adding a valid server /skms and key /ipk i get the error

Error: 0xC004F074 The Software Licensing Service reported that the computer could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.

Does this mean i haven't opened the correct port, or that this doesn't support windows 10/11 22H2/22H1 or both?

pykmsorg/py-kms:python3 UNRAID docker error

After update got an error on my UNRAID server:
Traceback (most recent call last): File "/usr/bin/entrypoint.py", line 33, in <module> print('Storing database file to ' + dbPath) NameError: name 'dbPath' is not defined
"python3" docker version worked before latest update. Now the "latest" docker version is working on UNRAID server. I hope you can fix this or maybe I need to change my configuration to get it working.

Freeze requirements properly

As already pointed out here: #66 (comment) we should freeze the requirements in e.g. a requirements.txt file.

As I worked with Python Poetry recently and was pleasantly surprised by its features, I would propose that system instead. What do you guys think? Any strong feelings out there?

Use dual-stack by default

I just wasted way too much time trying to figure out why the kms server was unreachable on my IPv6 K8s cluster just to find out that py-kms only listens on legacy IPv4 by default. It's 2022, this really shouldn't be happening anymore.

KMS server discovery

I added a DNS record for py-kms in pihole using the method shown here. Linkie

A fresh install of Win 10 Pro on the client machine using the VL key provided by MS it is not activated automatically.
Running nslookup -type=srv _vlmcs._tcp from the client machine shows the py-kms server.
I enter the key again manually using slmgr /ipk VLKEY just to make sure it is correct.
Running slmgr /ato gives the following error (see attached screencaps)
If I specify the kms server using slmgr /skms mykms.server then run slmgr /ato it activates successfully.

Am I doing something wrong?

Thank you for your time.

BTW I am using the latest py-kms

2021-12-12 23_34_24-Test - VMware Workstation
2021-12-12 23_35_20-Test - VMware Workstation
2021-12-12 23_35_46-Test - VMware Workstation
2021-12-12 23_36_13-Test - VMware Workstation

Issue with Office LTSC Standard 2021

I am not able to activate

DOCKER Log:
Sat, 23 Oct 2021 18:42:14 INFO RPC bind request received.
Sat, 23 Oct 2021 18:42:14 INFO RPC bind acknowledged.
Sat, 23 Oct 2021 18:42:14 INFO Received activation request.
Sat, 23 Oct 2021 18:42:14 INFO Received V6 request on Sat Oct 23 18:42:14 2021.
Sat, 23 Oct 2021 18:42:14 WARNING Too many clients ! Fixed with 10
Sat, 23 Oct 2021 18:42:15 INFO Machine Name: XXX
Sat, 23 Oct 2021 18:42:15 INFO Client Machine ID: XYXYXYXY
Sat, 23 Oct 2021 18:42:15 INFO Application ID: Office 15 (2013) / 16 (2016) / 17 (2019)
Sat, 23 Oct 2021 18:42:15 INFO SKU ID: Office LTSC Standard 2021
Sat, 23 Oct 2021 18:42:15 INFO License Status: Grace Period
Sat, 23 Oct 2021 18:42:15 INFO Request Time: 2021-10-23 18:42:12 UTC (UTC+0000)
Sat, 23 Oct 2021 18:42:15 INFO Connection closed: 172.17.0.1:59084

In the Windows Terminal I get the following error details:
ERROR CODE: 0xC004F074
ERROR DESCRIPTION: The Software Licensing Service reported that the product could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.

Any ideas?

Latest sqlite-web require extension none

with latest sqlite-web commits, extensions are expected and cannot be null. not a bug in this project, but has definitely an impact..

kms       | + /usr/bin/python3 /home/sqlite_web/sqlite_web.py -rx -e none -H 0.0.0.0 /db/pykms_database.db
kms       | Traceback (most recent call last):
kms       |   File "/home/sqlite_web/sqlite_web.py", line 898, in <module>
kms       |     main()
kms       |   File "/home/sqlite_web/sqlite_web.py", line 870, in main
kms       |     options.extensions)
kms       | AttributeError: 'Values' object has no attribute 'extensions'

Set own UID/GID in Docker

I have TZ ok (through env var)+ log for client on stdout.
I try to change now uid/gid of user as I need to have specific id/gid on mounted volume and drop root privileges after having set TZ and UID/GID.. without any luck til now. I might have to split entrypoint in 2. My fork might be already to different from yours.

Originally posted by @edgd1er in #10 (comment)

docker :latest and :minimal TypeError

Unfortunately latest and minimal tag have been broken for several days now

python3 tag works fine :)

latest and minimal tag crashes at startup with:

Storing database file to db/pykms_database.db
Traceback (most recent call last):
  File "/usr/bin/entrypoint.py", line 44, in <module>
    sqliteProcess = subprocess.Popen(['/usr/bin/python3', '/home/sqlite_web/sqlite_web.py', '-H', os.environ.get('IP'), '--read-only', '-x', dbPath, '-p', os.environ.get('SQLITE_PORT')])
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1639, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not NoneType

Can’t keep in background on docker

Hello,I recently found something strange. The docker container on my Debian server can't keep in the background.I must connect to my server with Putty and it will run. If I exit the terminal,it will stop working.

Permission error setting up docker-compose via Docs

Just tried the current setup related into Docs with following docker-compose:

version: '3'

services:
  kms:
    image: ghcr.io/py-kms-organization/py-kms:python3
    ports:
      - 1688:1688
      - 8080:8080
    environment:
      - IP=0.0.0.0
      - SQLITE=true
      - HWID=RANDOM
      - LOGLEVEL=INFO
      - LOGFILE=/dev/stdout
    restart: always
    volumes:
      - ./db:/home/py-kms/db
      - /etc/localtime:/etc/localtime:ro

Resultet into this Output:

`Creating network "py-kms_default" with the default driver
Creating py-kms_kms_1 ... done
Attaching to py-kms_kms_1
kms_1  | Tue, 21 Dec 2021 04:59:32 INFO     Log level: INFO
kms_1  | Tue, 21 Dec 2021 04:59:32 INFO     Setting timzeone to America/Chicago
kms_1  | Tue, 21 Dec 2021 04:59:32 INFO     Setting gid to '1000'.
kms_1  | Tue, 21 Dec 2021 04:59:32 INFO     Setting uid to '100'.
kms_1  | Tue, 21 Dec 2021 04:59:32 INFO     Storing database file to /home/py-kms/db/pykms_database.db
kms_1  | Traceback (most recent call last):
kms_1  |   File "/home/py-kms/pykms_Server.py", line 640, in <module>
kms_1  |     server_main_no_terminal()
kms_1  |   File "/home/py-kms/pykms_Server.py", line 571, in server_main_no_terminal
kms_1  |     server_with_gui()
kms_1  |   File "/home/py-kms/pykms_Server.py", line 564, in server_with_gui
kms_1  |     root = pykms_GuiBase.KmsGui()
kms_1  |   File "/home/py-kms/pykms_GuiBase.py", line 68, in __init__
kms_1  |     tk.Tk.__init__(self, *args, **kwargs)
kms_1  |   File "/usr/lib/python3.9/tkinter/__init__.py", line 2270, in __init__
kms_1  |     self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
kms_1  | _tkinter.TclError: no display name and no $DISPLAY environment variable
kms_1  | 
kms_1  | During handling of the above exception, another exception occurred:
kms_1  | 
kms_1  | Traceback (most recent call last):
kms_1  |   File "/home/py-kms/pykms_Server.py", line 642, in <module>
kms_1  |     server_main_terminal()
kms_1  |   File "/home/py-kms/pykms_Server.py", line 543, in server_main_terminal
kms_1  |     server_check()
kms_1  |   File "/home/py-kms/pykms_Server.py", line 409, in server_check
kms_1  |     check_setup(srv_config, srv_options, loggersrv, where = "srv")
kms_1  |   File "/home/py-kms/pykms_Misc.py", line 549, in check_setup
kms_1  |     logger_create(logger, config, mode = 'a')
kms_1  |   File "/home/py-kms/pykms_Misc.py", line 179, in logger_create
kms_1  |     hand_rotate = RotatingFileHandler(filename = config['logfile'][0], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512),
kms_1  |   File "/usr/lib/python3.9/logging/handlers.py", line 153, in __init__
kms_1  |     BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding,
kms_1  |   File "/usr/lib/python3.9/logging/handlers.py", line 58, in __init__
kms_1  |     logging.FileHandler.__init__(self, filename, mode=mode,
kms_1  |   File "/usr/lib/python3.9/logging/__init__.py", line 1146, in __init__
kms_1  |     StreamHandler.__init__(self, self._open())
kms_1  |   File "/usr/lib/python3.9/logging/__init__.py", line 1175, in _open
kms_1  |     return open(self.baseFilename, self.mode, encoding=self.encoding,
kms_1  | PermissionError: [Errno 13] Permission denied: '/dev/stdout'
kms_1  | Tue, 21 Dec 2021 04:59:37 INFO     Starting a dummy activation to ensure the database file is created
kms_1  | Traceback (most recent call last):
kms_1  |   File "/home/py-kms/pykms_Client.py", line 364, in <module>
kms_1  |     clt_main(with_gui = False)
kms_1  |   File "/home/py-kms/pykms_Client.py", line 275, in clt_main
kms_1  |     client_check()
kms_1  |   File "/home/py-kms/pykms_Client.py", line 124, in client_check
kms_1  |     check_setup(clt_config, clt_options, loggerclt, where = "clt")
kms_1  |   File "/home/py-kms/pykms_Misc.py", line 549, in check_setup
kms_1  |     logger_create(logger, config, mode = 'a')
kms_1  |   File "/home/py-kms/pykms_Misc.py", line 179, in logger_create
kms_1  |     hand_rotate = RotatingFileHandler(filename = config['logfile'][0], mode = mode, maxBytes = int(config['logsize'] * 1024 * 512),
kms_1  |   File "/usr/lib/python3.9/logging/handlers.py", line 153, in __init__
kms_1  |     BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding,
kms_1  |   File "/usr/lib/python3.9/logging/handlers.py", line 58, in __init__
kms_1  |     logging.FileHandler.__init__(self, filename, mode=mode,
kms_1  |   File "/usr/lib/python3.9/logging/__init__.py", line 1146, in __init__
kms_1  |     StreamHandler.__init__(self, self._open())
kms_1  |   File "/usr/lib/python3.9/logging/__init__.py", line 1175, in _open
kms_1  |     return open(self.baseFilename, self.mode, encoding=self.encoding,
kms_1  | PermissionError: [Errno 13] Permission denied: '/dev/stdout'`

Could "fix" the Permission issue on /dev/stdout temporarly by using a fixed location with .log ending within the docker-compose file to another folder but the DB issue stays.

Unable to open database file in read-only mode. Ensure that the database exists in order to use read-only mode.

After latest docker update got the message: Unable to open database file in read-only mode. Ensure that the database exists in order to use read-only mode.

Debug log is here:

Fri, 17 Dec 2021 08:46:20 INFO Log level: DEBUG
Fri, 17 Dec 2021 08:46:20 INFO Setting timzeone to Europe/Kiev
Fri, 17 Dec 2021 08:46:20 INFO Setting gid to '1000'.
Fri, 17 Dec 2021 08:46:20 INFO Setting uid to '100'.
Fri, 17 Dec 2021 08:46:20 INFO Storing database file to /home/py-kms/db/pykms_database.db
Fri, 17 Dec 2021 08:46:20 DEBUG server_cmd: /usr/bin/python3 -u pykms_Server.py 0.0.0.0 1688 -l 1033 -c 26 -a 120 -r 10080 -w RANDOM -V DEBUG -F STDOUT -s /home/py-kms/db/pykms_database.db
Fri, 17 Dec 2021 08:46:21 INFO TCP server listening at 0.0.0.0 on port 1688
Fri, 17 Dec 2021 08:46:21 INFO HWID: E6C388F490944342
Fri, 17 Dec 2021 08:46:25 INFO Starting a dummy activation to ensure the database file is created
Fri, 17 Dec 2021 08:46:25 DEBUG client_cmd: /usr/bin/python3 -u pykms_Client.py 0.0.0.0 1688 -m Windows10 -n DummyClient -c ae3a27d1-b73a-4734-9878-70c949815218 -V DEBUG -F STDOUT
Fri, 17 Dec 2021 08:46:25 INFO Connecting to 0.0.0.0 on port 1688
Fri, 17 Dec 2021 08:46:25 INFO Connection successful !
Fri, 17 Dec 2021 08:46:25 INFO Connection accepted: 127.0.0.1:59122
Fri, 17 Dec 2021 08:46:25 INFO Sending RPC bind request...
Fri, 17 Dec 2021 08:46:25 INFO RPC bind request received.
Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Request Bytes:

05000b13100000007400000001000000d016d0160000000002000000000001007521c8514e845047b0d8ec255555bc060100
0000045d888aeb1cc9119fe808002b10486002000000010001007521c8514e845047b0d8ec255555bc06010000002c1cb76c
12984045030000000000000001000000

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Request:

MSRPCHeader
ver_major: {5}
ver_minor: {0}
type: {11}
flags: {19}
representation: {16}
frag_len: {116}
auth_len: {0}
call_id: {1}
dataLen: {100}
pduData: {b'\xd0\x16\xd0\x16\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00u!\xc8QN\x84PG\xb0\xd8\x
ec%UU\xbc\x06\x01\x00\x00\x00\x04]\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00+\x10H`\x02\x00\x00\x00\x0
1\x00\x01\x00u!\xc8QN\x84PG\xb0\xd8\xec%UU\xbc\x06\x01\x00\x00\x00,\x1c\xb7l\x12\x98@E\x03\x00\x00\x
00\x00\x00\x00\x00\x01\x00\x00\x00'}
_pad: {0}
pad: {''}
_sec_trailer: {0}
sec_trailer: {''}
auth_dataLen: {0}
auth_data: {''}

MSRPCBind
max_tfrag: {5840}
max_rfrag: {5840}
assoc_group: {0}
ctx_num: {2}
Reserved: {0}
Reserved2: {0}
_ctx_items: {88}
ctx_items: {<pykms_RpcBind.MSRPCBind.CtxItemArray object at 0x149c8372a5e0>}

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Response:

MSRPCBindAck
ver_major: {5}
ver_minor: {0}
type: {12}
flags: {19}
representation: {16}
frag_len: {84}
auth_len: {0}
call_id: {1}
max_tfrag: {5840}
max_rfrag: {5840}
assoc_group: {274972479}
SecondaryAddrLen: {5}
SecondaryAddr: {'1688'}
Pad: {b'\x00'}
ctx_num: {2}
ctx_items: {b'\x00\x00\x00\x00\x04]\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00+\x10H`\x02\x00\x00\x00\x
03\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}
sec_trailer: {b''}
auth_data: {b''}
pduData: {b''}
pad: {b''}

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Response Bytes:

05000c13100000005400000001000000d016d0163fbf631005003136383800000200000000000000045d888aeb1cc9119fe8
08002b10486002000000030003000000000000000000000000000000000000000000

Fri, 17 Dec 2021 08:46:25 INFO RPC bind acknowledged.
Fri, 17 Dec 2021 08:46:25 INFO RPC bind acknowledged.
Traceback (most recent call last):
File "/home/py-kms/pykms_Client.py", line 364, in <module>
clt_main(with_gui = False)
File "/home/py-kms/pykms_Client.py", line 280, in clt_main
client_create(clt_sock)
File "/home/py-kms/pykms_Client.py", line 221, in client_create
kmsRequest = createKmsRequest()
File "/home/py-kms/pykms_Client.py", line 318, in createKmsRequest
if clt_config['KMSProtocolMajorVersion'] == 4:
KeyError: 'KMSProtocolMajorVersion'
Fri, 17 Dec 2021 08:46:25 WARNING No data received.
Fri, 17 Dec 2021 08:46:25 INFO Connection closed: 127.0.0.1:59122
Fri, 17 Dec 2021 08:46:25 DEBUG sqlite_cmd: /usr/bin/python3 -u /home/sqlite_web/sqlite_web.py -H 0.0.0.0 --read-only -x /home/py-kms/db/pykms_database.db -p 8080
Fri, 17 Dec 2021 08:46:25 INFO Starting a dummy activation to ensure the database file is created
Fri, 17 Dec 2021 08:46:25 DEBUG client_cmd: /usr/bin/python3 -u pykms_Client.py 0.0.0.0 1688 -m Windows10 -n DummyClient -c ae3a27d1-b73a-4734-9878-70c949815218 -V DEBUG -F STDOUT
Fri, 17 Dec 2021 08:46:25 INFO Connecting to 0.0.0.0 on port 1688
Fri, 17 Dec 2021 08:46:25 INFO Connection successful !
Fri, 17 Dec 2021 08:46:25 INFO Connection accepted: 127.0.0.1:59122
Fri, 17 Dec 2021 08:46:25 INFO Sending RPC bind request...
Fri, 17 Dec 2021 08:46:25 INFO RPC bind request received.
Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Request Bytes:

05000b13100000007400000001000000d016d0160000000002000000000001007521c8514e845047b0d8ec255555bc060100
0000045d888aeb1cc9119fe808002b10486002000000010001007521c8514e845047b0d8ec255555bc06010000002c1cb76c
12984045030000000000000001000000

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Request:

MSRPCHeader
ver_major: {5}
ver_minor: {0}
type: {11}
flags: {19}
representation: {16}
frag_len: {116}
auth_len: {0}
call_id: {1}
dataLen: {100}
pduData: {b'\xd0\x16\xd0\x16\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00u!\xc8QN\x84PG\xb0\xd8\x
ec%UU\xbc\x06\x01\x00\x00\x00\x04]\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00+\x10H`\x02\x00\x00\x00\x0
1\x00\x01\x00u!\xc8QN\x84PG\xb0\xd8\xec%UU\xbc\x06\x01\x00\x00\x00,\x1c\xb7l\x12\x98@E\x03\x00\x00\x
00\x00\x00\x00\x00\x01\x00\x00\x00'}
_pad: {0}
pad: {''}
_sec_trailer: {0}
sec_trailer: {''}
auth_dataLen: {0}
auth_data: {''}

MSRPCBind
max_tfrag: {5840}
max_rfrag: {5840}
assoc_group: {0}
ctx_num: {2}
Reserved: {0}
Reserved2: {0}
_ctx_items: {88}
ctx_items: {<pykms_RpcBind.MSRPCBind.CtxItemArray object at 0x149c8372a5e0>}

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Response:

MSRPCBindAck
ver_major: {5}
ver_minor: {0}
type: {12}
flags: {19}
representation: {16}
frag_len: {84}
auth_len: {0}
call_id: {1}
max_tfrag: {5840}
max_rfrag: {5840}
assoc_group: {274972479}
SecondaryAddrLen: {5}
SecondaryAddr: {'1688'}
Pad: {b'\x00'}
ctx_num: {2}
ctx_items: {b'\x00\x00\x00\x00\x04]\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00+\x10H`\x02\x00\x00\x00\x
03\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}
sec_trailer: {b''}
auth_data: {b''}
pduData: {b''}
pad: {b''}

Fri, 17 Dec 2021 08:46:25 DEBUG RPC Bind Response Bytes:

05000c13100000005400000001000000d016d0163fbf631005003136383800000200000000000000045d888aeb1cc9119fe8
08002b10486002000000030003000000000000000000000000000000000000000000

Fri, 17 Dec 2021 08:46:25 INFO RPC bind acknowledged.
Fri, 17 Dec 2021 08:46:25 INFO RPC bind acknowledged.
Traceback (most recent call last):
File "/home/py-kms/pykms_Client.py", line 364, in <module>
clt_main(with_gui = False)
File "/home/py-kms/pykms_Client.py", line 280, in clt_main
client_create(clt_sock)
File "/home/py-kms/pykms_Client.py", line 221, in client_create
kmsRequest = createKmsRequest()
File "/home/py-kms/pykms_Client.py", line 318, in createKmsRequest
if clt_config['KMSProtocolMajorVersion'] == 4:
KeyError: 'KMSProtocolMajorVersion'
Fri, 17 Dec 2021 08:46:25 WARNING No data received.
Fri, 17 Dec 2021 08:46:25 INFO Connection closed: 127.0.0.1:59122
Fri, 17 Dec 2021 08:46:25 DEBUG sqlite_cmd: /usr/bin/python3 -u /home/sqlite_web/sqlite_web.py -H 0.0.0.0 --read-only -x /home/py-kms/db/pykms_database.db -p 8080
Unable to open database file in read-only mode. Ensure that the database exists in order to use read-only mode.

Now the SQLITE WebUI is not working but the KMS Activation seems to work.

Logfile permission issue

I just switched from SystemRage to your KMs repo,

Uppon creation the docker container works just fine.

When you specify

LOGFILE environment
LOGFILE=/home/py-kms/db/pykms_server.log

and restart docker the log get created and can be written permission 644

If the container is then restartet the permission changes to 411 and even manually changeing it to 644 does nothing.
I did not change anything else except the logfile.

For the container to work again i need to manually delete the lofgile and restart the docker container.

Connect GUI to remote server?

This would allow someone to run pykms in Docker and then use a client program to have access to the GUI. Curently we have no way to view to GUI of a pykms server in Docker, so having a way to 'connect' to it would allow us to view the GUI. This would also allow for management of a pykms server remotely (or across the internet if the port has been forwarded correctly.

ls: /home/py-kms/db/pykms_database.db: No such file or directory after deddf0c

My docker script is like

#!/bin/sh
CONTAINER_NAME=py-kms
docker rm -f ${CONTAINER_NAME}
docker run -itd \
	--name=${CONTAINER_NAME} \
	--restart=always \
	-e TZ=Asia/Shanghai \
	-p 1688:1688 \
	pykmsorg/py-kms:python3

and after pulling the latest docker image and starting the script, an error occured.

Mon, 01 Nov 2021 11:25:33 INFO     Log level: INFO
Mon, 01 Nov 2021 11:25:33 INFO     Setting timzeone to Asia/Shanghai
ls: /home/py-kms/db/pykms_database.db: No such file or directory
Traceback (most recent call last):
  File "/usr/bin/entrypoint.py", line 62, in <module>
    subprocess.call(PYTHON3 + " -u /usr/bin/start.py", preexec_fn=change_uid_grp(), shell=True)
  File "/usr/bin/entrypoint.py", line 36, in change_uid_grp
    loggersrv.debug("%s" %str(subprocess.check_output("ls -al " + dbPath, shell=True)))
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'ls -al /home/py-kms/db/pykms_database.db' returned non-zero exit status 1.

I guess it should be introduced in deddf0c or its near parents, for the docker image a week ago worked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.