Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


seriously I don't get wtf is going on with this Kerberos Auth problem switching between two accounts. New keytab is generated and spn assigned to link the new account to the serverbut it doesn't work, and the old keytab somehow still does even though the spn is no longer linked to that account???

if I run kinit on the new keytab it fails which maybe points to the password in the keytab being wrong, but if the password was wrong surely ktpass would have failed to generate? or does ktpass not actually validate it?

if it's a bad password then I will be so pissed off with our support team who are supposed to manage accounts and are the ones that provided it to the domain admins to generate the keytab

Adbot
ADBOT LOVES YOU

Shaggar
Apr 26, 2006

Powerful Two-Hander posted:

BORN TO AUTHENTICATE
KERBEROS IS A gently caress
Negotiate Em All 1989
I am SPN man
410,757,864,530 FAILED LOGINS

sb hermit
Dec 13, 2016





I dunno much about kerberos except it's a pile of poo poo on good days and I've had a hell of a problem getting delegated credentials to work on a custom python-based web service until I gave up and used a different mechanism.

But all of your issues kinda points to something being stale. Can you try authenticating to a different kdc?

Shaggar
Apr 26, 2006
it works fine in windows for the most part. when people complain it's usually cause they're running into a security constraint like delegation or token relaying. or if they're doing Linux poo poo

Shaggar
Apr 26, 2006
re: passwords I use managed accounts as much as possible because service accounts with human managed credentials are a terrible idea.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

re: passwords I use managed accounts as much as possible because service accounts with human managed credentials are a terrible idea.

ugh I know but when I quizzed our server engineering guys on this they went "yeah that's a good idea we'll look at it" and that was like 6 months ago

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


sb hermit posted:

I dunno much about kerberos except it's a pile of poo poo on good days and I've had a hell of a problem getting delegated credentials to work on a custom python-based web service until I gave up and used a different mechanism.

But all of your issues kinda points to something being stale. Can you try authenticating to a different kdc?

so there's one funny thing: the krb5.ini config had a non existent server for the domain, I updated that this morning to use a server that actually exists and expected the existing account/keytab to then fail out because it must have just been caching a ticket (for like, 3 years), but no, old account that the spn was removed from still works :confused:

Shaggar
Apr 26, 2006

Powerful Two-Hander posted:

ugh I know but when I quizzed our server engineering guys on this they went "yeah that's a good idea we'll look at it" and that was like 6 months ago

it's like 5 minutes of setup for the domain and then 5 minutes per account. the only problem is some applications' credential uis don't support it. otherwise it's better in every way than using user accounts.

outhole surfer
Mar 18, 2003

Shaggar posted:

it works fine in windows for the most part. when people complain it's usually cause they're running into a security constraint like delegation or token relaying. or if they're doing Linux poo poo

it's the absolute tits in linux these days, assuming you're in a linux-first environment.

linux speaking to FreeIPA, Samba, or even directly with ldap-of-choice/(mit-krb5 or heimdall) makes for happy fun times

linux speaking to AD for anything but the most absolutely simple of use cases, and you're gonna have a bad time

echinopsis
Apr 13, 2004

by Fluffdaddy
can I ask a question about JSON

I'm trying to hold all my crime data (read only stuff) in a JSON file, and I am unsure of how to have the layout.

my goal would be to access it like
code:
JSONFile.crimes[12].name
here's what I have with thr JSON file so far
code:
{
  "crimes": [
    {
      "buttonid": "",
      "name": "",
      "cost": 0,
      "requiredNoto": 0,
      "moneyEarned": 0,
      "notoEarned": 0,
      "timeToCompleteInSeconds": 0,
      "timeToCompleteInHours": 0
    },
    {
      "do more of the same"
    }
  ]
}

{
    "spiels":[
        {
            "buttonid":"some great words"
        },
        {
          do more of the same
        }
        
    ]
}
one large array for the crime data and a second large array that holds just some text/spiel/praragraph about the crimes


am I heading in the right direction?

outhole surfer
Mar 18, 2003

assuming you want to be able to map one spiel to many crimes, and buttonid is how you intend to join the two, sure. that said, as spiels grows, it will become increasingly inefficient, and you should probably pull your buttonid up to sit directly inside spiels[] with something like

code:
"spiels": [
  "someSpiel": {
    "name: "",
    "alltheothershit": "",
    "etc": "",
  }
]
where someSpiel is the value of buttonid for the spiel

edit: i am not a frontent person and just realized buttonid is unikely an id.

if you want to map crimes and spiels, you either need to put the spiel inside the crime, or provide an id to map between the two.

outhole surfer fucked around with this message at 23:42 on Jun 18, 2022

echinopsis
Apr 13, 2004

by Fluffdaddy
no I just separated them because I want to be able to view and edit the crime data without the spiel getting in the way

I have realised I was meant to have everything inside the one set of {} though, so I've changed that.

the tutorials do quite a good job of showing the same thing over and over, but I had to do a lot of searches to find out how to actually add a json file to my project. which now that I look at it was kind of obvious but still lol

nudgenudgetilt posted:

if you want to map crimes and spiels, you either need to put the spiel inside the crime, or provide an id to map between the two.

I should probably code a bit better, my buttonid is something like "loit" that is specific to each crime, and so once I have that I can access the relevant spiel with that. I hope

echinopsis
Apr 13, 2004

by Fluffdaddy
and wth chrome is complaining about my : after "crimes" and if I remove them it stops complaining but now vscode is sad

there is surprisingly little tutorial on the internet that helps you work out how to actually open a JSON file in your code and reference it. down the stack overflow rabbit hole I go

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Instead of making spiels an array, which means you'll need to scan the entire array to find the right spiel, you can just make it an object with keys directly:

code:

{
  crimes: [
    // ...
  ],
  spiels: {
    loit: "stand around looking menacing",
    skate: "the crime is not being as good as tony hawk" 
  }
}

Then you can just look up spiels[crime.buttonId] to get the text.

echinopsis
Apr 13, 2004

by Fluffdaddy

Jabor posted:

Instead of making spiels an array, which means you'll need to scan the entire array to find the right spiel, you can just make it an object with keys directly:

code:
{
  crimes: [
    // ...
  ],
  spiels: {
    loit: "stand around looking menacing",
    skate: "the crime is not being as good as tony hawk" 
  }
}
Then you can just look up spiels[crime.buttonId] to get the text.

oh.. that makes a lot of sense

why tho is chrome spitting the dummy about that first colon? some online json validator says my file is fine.

outhole surfer
Mar 18, 2003

echinopsis posted:

there is surprisingly little tutorial on the internet that helps you work out how to actually open a JSON file in your code and reference it. down the stack overflow rabbit hole I go

you're trying to think about several relatively simple operations (open file, read it into a string, deserialize that string into an object) as one complex operation.

instead decompose your problems when searching for them. search for how to open a file in your language of choice, then how to read that file into a string, and finally how to parse or deserialize that string into an object.

echinopsis
Apr 13, 2004

by Fluffdaddy

nudgenudgetilt posted:

you're trying to think about several relatively simple operations (open file, read it into a string, deserialize that string into an object) as one complex operation.

instead decompose your problems when searching for them. search for how to open a file in your language of choice, then how to read that file into a string, and finally how to parse or deserialize that string into an object.

you're probably right, although I would have thought it was a common enough set of problems that tutorials addressing one would at least mention the others.

thanks for the advice :)

hobbesmaster
Jan 28, 2008

echinopsis posted:

you're probably right, although I would have thought it was a common enough set of problems that tutorials addressing one would at least mention the others.

maybe, but in general you'll get better quality results looking for the individual things even if the others may be covered in the same article

outhole surfer
Mar 18, 2003

echinopsis posted:

you're probably right, although I would have thought it was a common enough set of problems that tutorials addressing one would at least mention the others.

thanks for the advice :)

part of what you're bumping into is that by the time you need to parse a json file, you're generally expected to have already tackled the concept of opening/working with files, and parsing json strings (from hardcoded vars or apis) into objects, so nobody explicitly calls out "here is how you go from file to object"

echinopsis
Apr 13, 2004

by Fluffdaddy

nudgenudgetilt posted:

part of what you're bumping into is that by the time you need to parse a json file, you're generally expected to have already tackled the concept of opening/working with files, and parsing json strings (from hardcoded vars or apis) into objects, so nobody explicitly calls out "here is how you go from file to object"

ah yes the constant pitfalls from self teaching lol

cool av
Mar 2, 2013

echinopsis posted:

oh.. that makes a lot of sense

why tho is chrome spitting the dummy about that first colon? some online json validator says my file is fine.

what's the actual json causing that error?

echinopsis
Apr 13, 2004

by Fluffdaddy

cool av posted:

what's the actual json causing that error?

oh I had copied someone elses example which used <-script type="text/javascript"-> in the html, when I changed this to "json" it fixed it. idk if it's meant to be json but it doesn't complain anymore

e: but I am thinking about giving up on this approach for now and just using an external data.js file instead. every solution I find assumes I'm node.js or jQuery, and my patience is wearing thin. and putting the data in an external js file is the same but different anyway, it's just a way to get it out of the main.js file

echinopsis fucked around with this message at 03:56 on Jun 19, 2022

PIZZA.BAT
Nov 12, 2016


:cheers:


what's the correct way in java to tell windows to not go to sleep or hibernate? i'm running a really long term job on my personal desktop so i don't want to disable hibernate entirely- only when my job is running

CarForumPoster
Jun 26, 2013

⚡POWER⚡

PIZZA.BAT posted:

what's the correct way in java to tell windows to not go to sleep or hibernate? i'm running a really long term job on my personal desktop so i don't want to disable hibernate entirely- only when my job is running

I dont have a way in Java. I use Don't Sleep for this purpose, works well.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

PIZZA.BAT posted:

what's the correct way in java to tell windows to not go to sleep or hibernate? i'm running a really long term job on my personal desktop so i don't want to disable hibernate entirely- only when my job is running

on macos there’s a built in command for this called caffeinate. maybe searching for a windows equivalent would turn up something?

animist
Aug 28, 2018
get a mouse jiggler dongle that Runs Java

Shaggar
Apr 26, 2006

PIZZA.BAT posted:

what's the correct way in java to tell windows to not go to sleep or hibernate? i'm running a really long term job on my personal desktop so i don't want to disable hibernate entirely- only when my job is running

the kernel api call you want is SetThreadExecutionState https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate?redirectedfrom=MSDN

how you call that from java idk. set ES_CONTINUOUS on a native thread and as long as that thread stays alive (and you dont change the exec state) it should keep the system awake.

if you're lazy you could probably accomplish this by modifying something like this: https://gist.github.com/natesubra/e8ed71a1ed9521178a47c6c33c57db2b

Change it to something like:
launch ur java process
SetThreadExecutionState ES_CONTINUOUS
while(CheckIfJavaProcessIsRunning)
{
sleep 500
}

effectively the script process should keep the computer awake and then once the java process ends the script process should terminate itself, allowing the computer to sleep.

or just run that script as is and then run ur java thing and come back later.

hobbesmaster
Jan 28, 2008

Shaggar posted:

the kernel api call you want is SetThreadExecutionState https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate?redirectedfrom=MSDN

how you call that from java idk. set ES_CONTINUOUS on a native thread and as long as that thread stays alive (and you dont change the exec state) it should keep the system awake.

if you're lazy you could probably accomplish this by modifying something like this: https://gist.github.com/natesubra/e8ed71a1ed9521178a47c6c33c57db2b

Change it to something like:
launch ur java process
SetThreadExecutionState ES_CONTINUOUS
while(CheckIfJavaProcessIsRunning)
{
sleep 500
}

effectively the script process should keep the computer awake and then once the java process ends the script process should terminate itself, allowing the computer to sleep.

or just run that script as is and then run ur java thing and come back later.

another, possibly simpler, solution to his problem might be to have his java program launched by a batch file or ps script that calls powercfg.exe. use /list to get the GUID for your high performance or "no sleep" plan as well as your normal plan. call with activate with the high performance plan, run the java command, then have the command to set your normal power plan after it.

sb hermit
Dec 13, 2016





Or write a JNI package that utilizes the microsoft API

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

Powerful Two-Hander posted:

BORN TO AUTHENTICATE
KERBEROS IS A gently caress
Negotiate Em All 1989
I am SPN man
410,757,864,530 FAILED LOGINS

CarForumPoster
Jun 26, 2013

⚡POWER⚡

hobbesmaster posted:

another, possibly simpler, solution to his problem might be to have his java program launched by a batch file or ps script that calls powercfg.exe. use /list to get the GUID for your high performance or "no sleep" plan as well as your normal plan. call with activate with the high performance plan, run the java command, then have the command to set your normal power plan after it.

Not running a .bat to call it specifically but I had a laptop once that would sleep from inactivity no matter what, even if on high performance and no sleep configured. Don't sleep fixed this, though reformatting that laptop also fxed it, it was some policy or setting from Asus.

Soricidus
Oct 21, 2010
freedom-hating statist shill

sb hermit posted:

Or write a JNI package that utilizes the microsoft API

you don’t need to gently caress with jni these days unless you really want to. just use jna or jnr, they’re along the lines of python ctypes or w/e.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



is there a way to set a function as a @property on an object using setattr()? im getting the object from elsewhere so i cant change its definition, but i want to put an attribute on it that works as a @property

Python code:
def test_getter(self):
	# actually some complex stuff, this is just an example
	return 1

class TestObject:
	pass

	@property
	def normal(self):
		return 1

o = TestObject()
setattr(o, 'test', property(fget=test_getter))

assert isinstance(o, TestObject) # ok
assert o.normal == 1 # ok
print(o.test) # is a property object
assert o.test == 1 # fails

mystes
May 31, 2006

Carthag Tuek posted:

is there a way to set a function as a @property on an object using setattr()? im getting the object from elsewhere so i cant change its definition, but i want to put an attribute on it that works as a @property

Python code:
def test_getter(self):
	# actually some complex stuff, this is just an example
	return 1

class TestObject:
	pass

	@property
	def normal(self):
		return 1

o = TestObject()
setattr(o, 'test', property(fget=test_getter))

assert isinstance(o, TestObject) # ok
assert o.normal == 1 # ok
print(o.test) # is a property object
assert o.test == 1 # fails
If you change setattr(o, 'test', property(fget=test_getter)) to setattr(TestObject, 'test', property(fget=test_getter)) to add it to the class rather than the object it will work. If it's not acceptable to add it to the class you might have to do something else.

Corla Plankun
May 8, 2007

improve the lives of everyone
you probably have a good reason, but why can't you do this?

code:
class MyTestObject(TestObject):
  @property
  def test(self):
    return test_getter(self)

o = MyTestObject()
assert isinstance(o, TestObject) # ok
assert o.normal == 1 # ok
print(o.test) # is a property object
assert o.test == 1 # ok
i have written a lot of python and never had to mess with setattr

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


Corla Plankun posted:

you probably have a good reason, but why can't you do this?

code:
class MyTestObject(TestObject):
  @property
  def test(self):
    return test_getter(self)

o = MyTestObject()
assert isinstance(o, TestObject) # ok
assert o.normal == 1 # ok
print(o.test) # is a property object
assert o.test == 1 # ok
i have written a lot of python and never had to mess with setattr

presumably they want to set it at runtime

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



yea, its a thing i get from 3rd party code at runtime, so im piggybacking on it lol

mystes posted:

If you change setattr(o, 'test', property(fget=test_getter)) to setattr(TestObject, 'test', property(fget=test_getter)) to add it to the class rather than the object it will work. If it's not acceptable to add it to the class you might have to do something else.

doy of course i should set it on the clas, not the instance. so this works :stoked:

Python code:
setattr(o.__class__, 'test', property(fget=test_getter))

Pythagoras a trois
Feb 19, 2004

I have a lot of points to make and I will make them later.
Pipenv is such a gaaaarbage

Why isn't virtualenv / virtualenvwrapper just the standard now and forever

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


I use pyenv for python versions and poetry for packages with virtualenv creation, works quite well for me

Adbot
ADBOT LOVES YOU

Zlodo
Nov 25, 2006
I dont use python and I wish I could say that it works well for me but I regularly have to use something written in python and I get exposed to all that python environment installation clown show

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply